#C5191. Minimum Manipulations

    ID: 48813 Type: Default 1000ms 256MiB

Minimum Manipulations

Minimum Manipulations

Given a string S consisting of lowercase letters, your task is to determine the minimum number of manipulations required to make all characters in the string identical. In one manipulation, you can change any single character to any other character. The optimal solution is to convert every character to the most frequent character in the string. Mathematically, the answer is given by:

$$|S| - \max_{c \in S}\{\mathrm{frequency}(c)\}$$

where \(|S|\) is the length of the string and \(\mathrm{frequency}(c)\) represents the count of character \(c\) in \(S\).

inputFormat

The input consists of a single line that contains the string S. The string only consists of lowercase English letters.

outputFormat

Output a single integer representing the minimum number of manipulations required to make all characters of S the same.

## sample
aaaa
0