#C8696. Minimum Operations to Uniform String
Minimum Operations to Uniform String
Minimum Operations to Uniform String
Given a string S of length N, determine the minimum number of operations required to make all characters in the string identical. In one operation, you can change any character to any other character. The optimal strategy is to change all characters that are not equal to the most frequent character. Mathematically, if the maximum frequency of any character is \(f_{max}\), then the answer is \(N - f_{max}\).
For instance, if N = 5 and S = "aabbc", the most frequent character appears 2 times, so the minimum operations required is \(5 - 2 = 3\).
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains an integer \(N\) representing the length of the string.
- The second line contains the string \(S\) of length \(N\) composed of lowercase English letters.
outputFormat
Print a single integer to standard output (stdout), which is the minimum number of operations required to make all characters in \(S\) identical.
## sample5
aabbc
3