[CF1907C] 消除相邻异字 (Removal of Unattractive Pairs)
Problem Statement
You are given a string of length consisting of lowercase Latin letters.
You may repeatedly select any two adjacent characters that are different and delete both of them, concatenating the remaining parts together.
Find the minimum possible length of after any number of operations.
Input
The first line contains (). Each test case consists of () followed by a lowercase string of length . The sum of does not exceed .
Output
For each test case, print the minimum possible length of .
Example
6
7
abacaba
2
aa
3
abc
4
aabb
5
aabcw
9
abacabaac
1
2
1
0
1
1
Note
- Constraints:,,。
- Source:Codeforces 1907C · Removal of Unattractive Pairs