program link2;
const
fin='link.in';
fou='link.out';
var
s:array[1..10000]of string;
p,max,i,n:longint;
ss,st:string;
f1,f2:text;
procedure init;
begin
assign(f1,fin);
assign(f2,fou);
reset(f1); rewrite(f2);
readln(f1,n);
readln(f1,s[1]);
p:=1; max:=1;
end;
begin
init;
for i:=2 to n do
begin
readln(f1,st);
inc(p);
repeat
ss:=copy(st,1,length(s[p-1]));
if ss=s[p-1] then
begin
s[p]:=st;
if max<p then max:=p;
break;
end;
dec(p);
until p=1;
if p=1 then s[p]:=st;
end;
write(f2,max);
close(f1); close(f2);
end.