9
lfpgbnlzyn
c
s
w
r
m
q
y
yinfblfcdhidphyfvgkxyuwomahiibbhnigdslsguhjkplibnhhrshtekwgefxeugyyyyy
 6
u
p
m
z
v
vv
 4
qe
nd
iqryhukieskfvaeettersinksrmazelxtgvartuz
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 6
nf
ysvchtjkfgsbyfzxjaykey
advqnf
wl
pi
ppppfvvmaebvhkoagppppp
 3
j
k
kkailgwqnxtdsttkkkkkkk
 4
o
yhnx
e
ennn
 10
j
dyfu
udzj
wwow
xtnw
f
c
q
o
gggg
 6
w
g
c
j
y
f
 4
r
o
w
wwwwwwwwww
 2
zxwp
ppppctfisvflhtjggg
 5
m
g
u
t
tttt
 2
n
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
 3
lt
en
eeeeeeeeee
 4
vr
hp
l
llbn

7 5 541 10 10 4 4 1 21 5 9 93 21 3
import java.util.PriorityQueue;
import java.util.Scanner;

public class Test {

    public static int length(String str){

        int i = 1;
        int count = 0;
        int maxCount = 0;
        if(str.length() > 1) {

            while(i < str.length()){

                if(str.charAt(i - 1) == str.charAt(i)) {
                    count++;
                    if(count > maxCount)
                        maxCount = count;
                }
                else count = 0;
                i++;
            }
        }

        return maxCount + 1;

    }

    public static String multiply(String s, String t){

        StringBuilder str = new StringBuilder();
        for (int j = 0; j < s.length(); j++) {
            str.append(t);
            str.append(s.charAt(j));
        }

        str.append(t);
        return str.toString();
    }

    public static void main(String[] args){

        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        PriorityQueue<String> queue1 = new PriorityQueue<>();

        for (int i = 0; i < N - 1; i++) {
            queue1.add(scan.nextLine());
            queue1.add(multiply(queue1.remove(), scan.nextLine()));
        }
        System.out.println(length(queue1.peek()));
    }
}
