program link(input,output);
var
i,j,k:longint;
flag:boolean;
n,ans,dep:longint;
a:array [1..100000] of string;
b:array [1..100000] of string;
c:array [1..10000] of longint;
function panduan(s1,s2:string):boolean;
var
i,j,k,l1,l2:longint;
judge:boolean;
begin
l1:=length(s1);
l2:=length(s2);
if l1>=l2 then panduan:=false
else
begin
i:=1;
judge:=true;
while judge and (i<=l1) do
begin
if s1[i]<>s2[i] then judge:=false
else i:=i+1;
end;
panduan:=judge;
end;
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]);
ans:=0;
dep:=1;
fillchar(b,sizeof(b),0);
b[1]:=a[1];
for i:= 2 to n do begin
flag:=true;
while (flag=true) do begin
if (panduan(b[dep],a[i])) then
begin
dep:=dep+1;
b[dep]:=a[i];
flag:=false;
end
else begin
if dep>ans then ans:=dep;
dep:=dep-1;
end;
end;
end;
if dep>ans then ans:=dep;
writeln(ans);
close(input);
close(output);
end.