#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#define mod 10000007
using namespace std;
struct node {
int from,to,dis,next;
};
struct node edge[100001];
int n,len[100001],hash[100001][51],dp[100001];
int head[100001],num,ans=0;
string word[100001];
inline void edge_add(int from,int to)
{
num++;
edge[num].to=to;
edge[num].from=from;
edge[num].next=head[from];
head[from]=num;
}
void dfs(int now,int pos,int be)
{
ans=max(now,ans);
for(int i=head[be];i;i=edge[i].next)
{
if(len[edge[i].to]<len[pos])
{
if(hash[edge[i].to][len[edge[i].to]-1]==hash[pos][len[edge[i].to]-1])
{
dfs(now+1,pos,edge[i].to);
return ;
}
}
}
edge_add(be,pos);
}
int main()
{
len[0]=1;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
dp[i]=1;
cin>>word[i];
len[i]=word[i].length();
for(int j=0;j<len[i];j++)
{
hash[i][j]=word[i][j]-‘a‘+1;
if(j) hash[i][j]+=(hash[i][j-1]*29)%mod;
hash[i][j]%=mod;
}
dfs(1,i,0);
}
cout<<ans<<endl;
return 0;
}