文理学院程序设计在线练习


AC!

Time Limit: 1 Second(s)    Memory Limit: 32 MB

Total Submission(s): 100   Accepted Submission(s): 30
Problem Description

Lets AC this problem!
In this problem, you are given a string and need find its longest substring which has the same number of character ‘A’ and character’C’ .
Notice that the string will only contain ‘A’ and ‘C’ which are all in uppercase letter and no longer than 1000000.

Input

The first line contains a T(T <= 10) which means the number of data sets
Each of next T lines contains a string mentioned above

Output

For each data set, output answer in one line

Sample Input
1
ACAA
Sample Output
2
Source

2018绍兴市联赛