Minimum Deletions to Make Frequency Unique

EASY · C · 2000ms

For inventory purposes, Antu wants to trim a list of item codes (a string) so that no two different codes share the exact same usage frequency. Given a string, print the minimum number of characters to delete so that no two distinct characters have the same frequency.

Input

One string S of lowercase letters.

Output

Minimum deletions.

Constraints

1 ≤ |S| ≤ 10^5

Sample Input

aab

Sample Output

0
main.c
Loading editor…

Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.

Minimum Deletions to Make Frequency Unique · DIU ContestHub