276 传统题

[CF1907C] 消除相邻异字 (Removal of Unattractive Pairs)

时间限制
2000ms
内存限制
256MiB
登顶 / 尝试
0/ 0
难度
3

[CF1907C] 消除相邻异字 (Removal of Unattractive Pairs)

Problem Statement

You are given a string ss of length nn 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 ss after any number of operations.

Input

The first line contains tt (1≤t≤1041 \le t \le 10^4). Each test case consists of nn (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5) followed by a lowercase string ss of length nn. The sum of nn does not exceed 2⋅1052 \cdot 10^5.

Output

For each test case, print the minimum possible length of ss.

Example

6
7
abacaba
2
aa
3
abc
4
aabb
5
aabcw
9
abacabaac
1
2
1
0
1
1

Note