Flipping Coins -------------- Francis is bored and passes the time by flipping coins. He knows that on average, half the flips should come up heads and the other half tails, but sometimes there are more of one than the other. Given the entire sequence, he wants to find the longest period of time when the number of heads is exactly equal to the number of tails. For example, if the coin flips are H T T T T T H H T, then the longest contiguous subsequence with equal numbers of heads and tails is either T H H T or T T H H, so the length of the longest such subsequence is 4. (Hint: It might help to imagine that Francis takes a random walk: one step to the left for heads and one to the right for tails) Input ----- You will be given multiple instances, each on a separate line. Each instance will consist of a positive integer n <= 10^6, followed by n charcters a_1 ... a_n separated by spaces. Each character is either a H or T. The end of the input will be indicated by a line containing a single 0. (Do not produce any output for this input line.) Output ------ For each input array a_1 ... a_n, output the largest k such that there exists an i such that a_i ... a_{i+k-1} contains equal numbers of H's and T's. Sample Input ------------ 9 H T T T T T H H T 2 H T 0 Sample Output ------------- 4 2