Program cog173;
Type
St=String[55];
Var
S:Array[1..10010]Of St;
R:St;
T,M,I,N:Longint;
Function Greater(Var A,B:St):Boolean;
Var
I:Longint;
Begin
If Length(A)<=Length(B) Then Exit(False);
For I:=1 To Length(B) Do
If A[I]<>B[I] Then Exit(False);
Exit(True);
End;
Begin
Assign(Input,'link.in');
Assign(Output,'link.out');
Reset(Input);
Rewrite(Output);
T:=0;
M:=0;
Readln(N);
Repeat
Readln(R);
While (T<>0) And (Not Greater(R,S[T])) Do Dec(T);
Inc(T);
S[T]:=R;
If M<T Then M:=T;
Dec(N);
Until N=0;
Writeln(M);
Close(Input);
Close(Output);
End.