#GYM104618D. Ice Cream Lasagna

Ice Cream Lasagna

Description

In betrayal of the ice cream cone tradition, Luogu is enjoying ice cream lasagna, consisting of a total of $n$ layers of ice cream, split by $n+1$ layers of crackers.

For the $i$th layer of ice cream, there are $c_i$ pieces of candies, each being either red or green, sprinkled in a certain order determined by Luogu's mysterious ways.

Luogu has a few rules he sets for himself when he enjoys his ice cream lasagna:

- The ice cream is always eaten top to down, i.e., from the $1$st layer to the $n$th layer,

- One layer of ice cream must be finished before eating the next layer,

- He will record the candies found in each layer in his mysterious order, that is, he will lift the $1$st layer of cracker, record the candies he see, put it back, lift the $2$nd layer of cracker, and so on until the candies observed from lifting the $n$th layer of cracker has been recorded.

Using the record, Luogu asks that you help him understand the uniformity of the dessert: specifically, the maximum amount of candies of the same color that he can eat consecutively (i.e., no skipping or reordering the layers of lasagna) as he enjoys his ice cream lasagna while adhering to the rules.

The first line consists of an integer, $n\ (1 \leq n \leq 2 \cdot 10^5)$, denoting the number of layers of ice cream found in the lasagna.

The next $n$ lines record details of the candies cound in the $i$th layer. Each line consists of a string, consisting of either 'R' or 'G', denoting red or green candy, respectively. It is guaranteed $c_i \geq 1$ for $1\leq i \leq n$, and $\sum_{i=1}^{n} c_i \leq 2\cdot 10^5$.

A single integer denoting the uniformity of the dessert.

Input

The first line consists of an integer, $n\ (1 \leq n \leq 2 \cdot 10^5)$, denoting the number of layers of ice cream found in the lasagna.

The next $n$ lines record details of the candies cound in the $i$th layer. Each line consists of a string, consisting of either 'R' or 'G', denoting red or green candy, respectively. It is guaranteed $c_i \geq 1$ for $1\leq i \leq n$, and $\sum_{i=1}^{n} c_i \leq 2\cdot 10^5$.

Output

A single integer denoting the uniformity of the dessert.

4
RGR
GGGG
GR
RRR
5
RGGGGGGG
GGGRGRGRGRG
GRGRGRGRGRGRGRGRGRGR
RRRRRRRRR
G
6
19