program link(input,output);
type
fu=array [1..1001] of shortstring;
fq=array [1..1001] of longint;
var
i,j,k:longint;
a:fu;
b:fq;
n,max,temp:longint;
function panduan(s1,s2:string):boolean;
var
i,j,k,l1,l2:longint;
judge:boolean;
begin
l1:=length(s1);
l2:=length(s2);
if l2>=l1 then panduan:=false
else
begin
i:=1;
judge:=true;
end;
repeat
if s1[i]<>s2[i] then
judge:=false
else
i:=i+1;
until (judge=false) or (i>=l2);
panduan:=judge;
end;
begin
assign(input,'link.in');
assign(output,'link.out');
reset(input);
rewrite(output);
readln(n);
for i:=1 to n do readln(a[i]);
close(input);
b[1]:=1;
for i:=2 to n do
begin
max:=1;
for j:=1 to i-1 do
begin
if panduan(a[i],a[j]) then temp:=b[j]+1
else temp:=1;
if temp>=max then
max:=temp;
end;
b[i]:=max;
end;
temp:=0;
temp:=b[1];
for k:=2 to n do
if b[i]>temp then
temp:=b[i];
writeln(temp);
close(output);
end.