program EmberAsh;
var
i,j,k,m,n,max,ss:longint;
a:array[1..10000]of string;
f:array[0..10000]of longint;
BEGIN
assign(input,'link.in');reset(input);
assign(output,'link.out');rewrite(output);
readln(n);
for i:=1 to n do
readln(a[i]);
{sort or not..that's a question......- -||}
for i:=1 to n do
for j:=i-1 downto 1 do
begin
if (pos(a[j],a[i])<>0) then
begin
if f[j]+1>f[i] then
f[i]:=f[j]+1
end;
end;
writeln(f[n]+1);
close(input);close(output);
END.