#K76377. Minimum Operations to Equalize a Binary String

    ID: 34629 Type: Default 1000ms 256MiB

Minimum Operations to Equalize a Binary String

Minimum Operations to Equalize a Binary String

You are given a string S consisting solely of the characters a and b. In one operation, you can change any character in S to its opposite (i.e. a to b or b to a).

Your task is to determine the minimum number of operations required to make all characters in the string identical. Mathematically, if count_a is the number of 'a's and count_b is the number of 'b's in the string, the answer is:

\(\min(\text{count_a},\,\text{count_b})\)

This problem tests your ability to efficiently process strings and compute basic counts.

inputFormat

The first line of input contains an integer T which denotes the number of test cases. Each of the following T lines contains a string S consisting only of characters a and b.

Note: Input is provided via standard input (stdin).

outputFormat

For each test case, output a single integer which is the minimum number of operations needed to make all characters in the string the same. Each output should be printed on its own line through standard output (stdout).

## sample
3
abb
aaaa
baaba
1

0 2

</p>