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