program elysian;
const
fin='link.in';fout='link.out';
var
f:array[0..50] of string;
c:array[1..10000] of string;
n,ans:longint;
f1,f2:text;
procedure init;
var
i,j:longint;
begin
assign(f1,fin);reset(f1);
readln(f1,n);
for i:=1 to n do
readln(f1,c[i]);
close(f1);
end;
procedure dp;
var
tmp,tmp2:string;
flag:boolean;
i,j,p:longint;
begin
f[1]:=c[1];p:=1;
for i:=2 to n do
begin
tmp:=copy(c[i],1,length(f[p]));
if tmp=f[p] then
begin
inc(p);
f[p]:=c[i];
if p>ans then ans:=p;
end
else
repeat
flag:=false;
tmp2:=copy(c[i],1,length(f[p-1]));
if tmp2=f[p-1] then begin f[p]:=c[i];flag:=true;end;
if flag=false then
begin
dec(p);
if p=1 then begin f[p]:=c[i];flag:=true;end;
end;
until flag=true;
end;
end;
begin
init;
dp;
assign(f2,fout);rewrite(f2);
writeln(f2,ans);
close(f2);
end.