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.regex.Matcher;
import java.util.regex.Pattern;
import java.util.*;

public class Main {

	public static String sumstr(String s0, String s1){

		String str = "";
		
		for(int i = 0; i<s0.length(); i++)
			str += s1 + Character.toString(s0.charAt(i));
		
		return str;
	}

    public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String n1 = sc.nextLine();
		int n = Integer.parseInt(n1);
		String s = "";
        String str = " ";
        int maxLen = 0;
        
        for(int i = 0; i<n; i++){
        	s = sc.nextLine();
        	str = sumstr(str, s);
        }
        
        Matcher m = Pattern.compile("(.)\\1+").matcher(str);
        while (m.find()) {
            String sub = m.group();
            if (sub.length() > maxLen) {
                maxLen = sub.length();
            }
        }
        System.out.println(maxLen);
    }
}