program link;
const
max=10000;
type
sx=array[1..max]of string;
var
f1,f2:text;
a:sx;
n,ans:integer;
procedure ini;
var
i:integer;
begin
assign(f1,'link.in');reset(f1);
assign(f2,'link.out');rewrite(f2);
readln(f1,n);
for i:=1 to n do readln(f1,a[i]);
close(f1);
ans:=0;
end;
procedure try(k:integer;step:integer;s:string);
var
i,j:integer;
begin
for i:=k to n do begin
j:=pos(s,a[i+1]);
if j=1 then try(i+1,step+1,a[i+1]);
if i=n then
if step>ans then ans:=step;
end;
end;
begin
ini;
try(1,1,a[1]);
write(f2,ans);
close(f2);
end.