program xmz;
var
x:array[1..10000]of string;
y:array[0..10000]of string;
a,n,b,s:integer;
f1,f2:text;
begin
assign(f1,'link.in');assign(f2,'link.out');
reset(f1);rewrite(f2);
readln(f1,n);
for a:=1 to n do
readln(f1,x[a]);
a:=0;
repeat
b:=b+1;
if (pos(y[a],x[b])=1)or(a=0) then
begin
a:=a+1;
y[a]:=x[b];
end
else
begin
if a>s then s:=a;
repeat a:=a-1; until (pos(y[a],x[b])=1)or(a=0);
a:=a+1;y[a]:=x[b];
end;
until n=b;
if a>s then s:=a;
writeln(f2,s);
close(f1);close(f2);
end.