CANDYSTRIPE
We have
Our two-year-old brother naturally prefers sweet chocolates. He won't complain if he eats any bitter chocolates as well. However, if at any moment he has eaten more bitter chocolates than sweet ones, he will burst into tears, and of course, we don't want to upset him.
We want to give our brother a contiguous segment of the original film, possibly by trimming from the beginning and/or the end. Our brother will start eating the chocolates one by one in order until they are finished, but we don't know from which end of the segment he will start.
Find the length of the longest segment of the original film that we can give to our brother, ensuring that he won't burst into tears.
Input:
The first line of the input will contain a positive integer
Output:
The output should contain
Constraints:
.- The length of each film will be
. - The total length of all films in each test case will not exceed
. - Time Limit:
sec. - Memory Limit:
MB. - For test cases with a total value of
, it will be . - For test cases with a total value of
, it will be .
Example of Input - Ouput:
input
5
BSBSSB
SSBBSS
SBSBSBBSSS
SSSBBSBSBSBBB
ΒΒΒΒ
output
4
6
5
5
0
Explanation of the example:
For the first film, the longest segment we can give to our brother is "
Comments