program MayLava;
var
stack:array[0..10000]of string;
n,p,max:longint;
procedure push(s:string);
begin
inc(p);
stack[p]:=s;
if p>max then max:=p;
end;
procedure pop;
begin
if p=0 then exit;
dec(p);
end;
procedure main;
var
f:text;
s:string;
i:longint;
begin
p:=0; max:=0;
assign(f,'link.in');
reset(f);
readln(f,n);
for i:=1 to n do begin
readln(f,s);
while pos(stack[p],s)=0 do begin
if p=0 then break;
pop;
end;
push(s);
end;
close(f);
end;
procedure print;
var
f:Text;
begin
assign(f,'link.out');
rewrite(f);
writeln(f,max);
close(f);
end;
BEGIN
main;
print;
END.