According to the new tax scheme, a new tax called the binary string tax was introduced! JJ has a binary string
of length . According to the tax scheme, for every occurrence of in , a tax of rupees will be charged, while for every occurrence of in , a tax ofrupees will be charged.
For example, if
, and , then has occurrence of and occurrences of , so the tax charged
JJ can rearrange the string
in any way he wants. He wants to minimize the amount of tax he has to pay. Can you help him do so?
Input Format
- The first line contains a single integer
- s only.
Output Format
For each test case, output the minimum amount of tax that JJ has to pay.
Constraints
Sample Input 1
2
4 7 3
1101
5 3 4
00000
Sample Output 1
3
0
Explanation
Test Case 1: JJ can rearrange
to for which the tax charged will bewhich is the minimum value of tax.
Test Case 2: The tax charged for the string
is which can not be reduced further.
No comments:
Post a Comment