program link;
type
word=array[1..10000]of string;
long=array[1..10000]of integer;
var
tot:integer;
x:word;
z:long;
n,l,max:integer;
procedure init;
var
i:integer;
begin
assign(input,'link.in');
reset(input);
assign(output,'link.out');
rewrite(output);
readln(n);
for i:=1 to n do
begin
readln(x[i]);
end;
close(input);
end;
procedure main;
var
i,j:integer;
begin
for i:=1 to n do
begin
z[i]:=1;
for j:=1 to i-1 do
if (pos(x[j],x[i])=1)and(z[i]<z[j]+1) then z[i]:=z[j]+1;
end;
end;
procedure print;
var
i:integer;
begin
max:=0;
for i:=1 to n do if max<z[i] then max:=z[i];
writeln(max);
close(output);
end;
begin
init;
main;
print;
end.