#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
string s[10010];
int len[10010],a[10010]={0},n,ans=0;
int main()
{
freopen("link.in","r",stdin);
freopen("link.out","w",stdout);
int i,j;
cin>>n;
for (i=1;i<=n;i++){
cin>>s[i];
len[i]=s[i].length();
}
for (i=1;i<=n;i++){
for (j=i-1;j>0;j--){
if (len[i]>len[j])
if (a[i]<a[j])
if (s[i].substr(0,len[j])==s[j])
a[i]=a[j];
}
a[i]++;
ans=max(ans,a[i]);
}
cout<<ans<<endl;
return 0;
}