#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod1=1e9+7,mod2=998244353,N=5e4+5;
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
string s[n];
for(int a=0;a<n;a++){
cin>>s[a];
}
int mn=1e9;
string S;
for(int a=0;a<n;a++){
if(s[a].size()<mn){
S=s[a];
mn=s[a].size();
}
}
bool check=0;
int ans=min((int)60,(int)S.size());
while(!check){
for(int i=0;i<=S.size()-ans;i++){
string B=S.substr(i,ans);
bool ch[n];
for(int b=0;b<n;b++){
if(s[b]!=S){
string A=s[b];
bool K[A.size()+1];
int dp[A.size()+1];
dp[0]=0;
for(int a=1;a<=A.size();a++){
dp[a]=(dp[a-1]*26+A[a-1]-94+mod1)%mod1;
}
int dp1[B.size()+1];
dp1[0]=0;
int sum=1;
for(int a=0;a<B.size();a++){
sum*=26;
sum%=mod1;
}
for(int a=1;a<=B.size();a++){
dp1[a]=(dp1[a-1]*26+B[a-1]-94+mod1)%mod1;
}
int m=0;
for(int a=B.size();a<=A.size();a++){
if((dp[a]%mod1-(dp[a-B.size()]*sum)%mod1+mod1)%mod1==dp1[B.size()]) K[a-B.size()+1]=1;
}
dp[0]=0;
for(int a=1;a<=A.size();a++){
dp[a]=(dp[a-1]*26+A[a-1]-94+mod2)%mod2;
}
dp1[0]=0;
sum=1;
for(int a=0;a<B.size();a++){
sum*=26;
sum%=mod2;
}
for(int a=1;a<=B.size();a++){
dp1[a]=(dp1[a-1]*26+B[a-1]-94+mod2)%mod2;
}
for(int a=B.size();a<=A.size();a++){
if((dp[a]%mod2-(dp[a-B.size()]*sum)%mod2+mod2)%mod2==dp1[B.size()]){
if(K[a-B.size()+1]){
ch[b]=1;
break;
}
}
}
}
else ch[b]=1;
}
bool ss=0;
for(int a=0;a<n;a++){
if(!ch[a]) ss=1;
}
if(!ss){
check=1;
break;
}
}
if(check) break;
else ans--;
}
cout<<ans;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBpbnQgbG9uZyBsb25nCmNvbnN0IGludCBtb2QxPTFlOSs3LG1vZDI9OTk4MjQ0MzUzLE49NWU0KzU7CnNpZ25lZCBtYWluKCkKewogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7CiAgICBjaW4udGllKDApOwogICAgY291dC50aWUoMCk7CiAgICBpbnQgbjsKICAgIGNpbj4+bjsKICAgIHN0cmluZyBzW25dOwogICAgZm9yKGludCBhPTA7YTxuO2ErKyl7CiAgICAgICAgY2luPj5zW2FdOwogICAgfQogICAgaW50IG1uPTFlOTsKICAgIHN0cmluZyBTOwogICAgZm9yKGludCBhPTA7YTxuO2ErKyl7CiAgICAgICAgaWYoc1thXS5zaXplKCk8bW4pewogICAgICAgICAgICBTPXNbYV07CiAgICAgICAgICAgIG1uPXNbYV0uc2l6ZSgpOwogICAgICAgIH0KICAgIH0KICAgIGJvb2wgY2hlY2s9MDsKICAgIGludCBhbnM9bWluKChpbnQpNjAsKGludClTLnNpemUoKSk7CiAgICB3aGlsZSghY2hlY2spewogICAgICAgIGZvcihpbnQgaT0wO2k8PVMuc2l6ZSgpLWFucztpKyspewogICAgICAgICAgICBzdHJpbmcgQj1TLnN1YnN0cihpLGFucyk7CiAgICAgICAgICAgIGJvb2wgY2hbbl07CiAgICAgICAgICAgIGZvcihpbnQgYj0wO2I8bjtiKyspewogICAgICAgICAgICAgICAgaWYoc1tiXSE9Uyl7CiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIEE9c1tiXTsKICAgICAgICAgICAgICAgICAgICBib29sIEtbQS5zaXplKCkrMV07CiAgICAgICAgICAgICAgICAgICAgaW50IGRwW0Euc2l6ZSgpKzFdOwogICAgICAgICAgICAgICAgICAgIGRwWzBdPTA7CiAgICAgICAgICAgICAgICAgICAgZm9yKGludCBhPTE7YTw9QS5zaXplKCk7YSsrKXsKICAgICAgICAgICAgICAgICAgICAgICAgZHBbYV09KGRwW2EtMV0qMjYrQVthLTFdLTk0K21vZDEpJW1vZDE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGludCBkcDFbQi5zaXplKCkrMV07CiAgICAgICAgICAgICAgICAgICAgZHAxWzBdPTA7CiAgICAgICAgICAgICAgICAgICAgaW50IHN1bT0xOwogICAgICAgICAgICAgICAgICAgIGZvcihpbnQgYT0wO2E8Qi5zaXplKCk7YSsrKXsKICAgICAgICAgICAgICAgICAgICAgICAgc3VtKj0yNjsKICAgICAgICAgICAgICAgICAgICAgICAgc3VtJT1tb2QxOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IoaW50IGE9MTthPD1CLnNpemUoKTthKyspewogICAgICAgICAgICAgICAgICAgICAgICBkcDFbYV09KGRwMVthLTFdKjI2K0JbYS0xXS05NCttb2QxKSVtb2QxOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpbnQgbT0wOwogICAgICAgICAgICAgICAgICAgIGZvcihpbnQgYT1CLnNpemUoKTthPD1BLnNpemUoKTthKyspewogICAgICAgICAgICAgICAgICAgICAgICBpZigoZHBbYV0lbW9kMS0oZHBbYS1CLnNpemUoKV0qc3VtKSVtb2QxK21vZDEpJW1vZDE9PWRwMVtCLnNpemUoKV0pIEtbYS1CLnNpemUoKSsxXT0xOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkcFswXT0wOwogICAgICAgICAgICAgICAgICAgIGZvcihpbnQgYT0xO2E8PUEuc2l6ZSgpO2ErKyl7CiAgICAgICAgICAgICAgICAgICAgICAgIGRwW2FdPShkcFthLTFdKjI2K0FbYS0xXS05NCttb2QyKSVtb2QyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkcDFbMF09MDsKICAgICAgICAgICAgICAgICAgICBzdW09MTsKICAgICAgICAgICAgICAgICAgICBmb3IoaW50IGE9MDthPEIuc2l6ZSgpO2ErKyl7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1bSo9MjY7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1bSU9bW9kMjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9yKGludCBhPTE7YTw9Qi5zaXplKCk7YSsrKXsKICAgICAgICAgICAgICAgICAgICAgICAgZHAxW2FdPShkcDFbYS0xXSoyNitCW2EtMV0tOTQrbW9kMiklbW9kMjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9yKGludCBhPUIuc2l6ZSgpO2E8PUEuc2l6ZSgpO2ErKyl7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmKChkcFthXSVtb2QyLShkcFthLUIuc2l6ZSgpXSpzdW0pJW1vZDIrbW9kMiklbW9kMj09ZHAxW0Iuc2l6ZSgpXSl7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZihLW2EtQi5zaXplKCkrMV0pewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoW2JdPTE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBlbHNlIGNoW2JdPTE7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYm9vbCBzcz0wOwogICAgICAgICAgICBmb3IoaW50IGE9MDthPG47YSsrKXsKICAgICAgICAgICAgICAgIGlmKCFjaFthXSkgc3M9MTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZighc3MpewogICAgICAgICAgICAgICAgY2hlY2s9MTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmKGNoZWNrKSBicmVhazsKICAgICAgICBlbHNlIGFucy0tOwogICAgfQogICAgY291dDw8YW5zOwp9Cg==