#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6+16;
int n, tot, ans;
int f[maxn];
class trie
{
public:
int c[30];
int have;
};
trie t[maxn];
void insert(string s)
{
int cur = 0;
for (int i = 0; i < s.size(); i++)
{
int j = s[i] - 'a';
if (t[cur].c[j] == 0)
{
t[cur].c[j] = tot;
}
cur = t[cur].c[j];
}
t[cur].have;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++)
{
string s;
cin >> s;
reverse(s.begin(), s.end());
insert(s);
}
for (int i = tot; i >= 0; i--)
{
f[i] = t[i].have;
int maxa = 0, maxb = 0;
for (int j = 0; j <= 'z' - 'a'; j++)
{
if (t[t[i].c[j]].have)
{
f[i]++;
if (f[t[i].c[j]] - 1 > maxa)
{
maxb = maxa;
maxa = f[t[i].c[j]] - 1;
}
else if (f[t[i].c[j]] - 1 > maxb)
{
maxb = f[t[i].c[j]] - 1;
}
}
}
f[i] += maxa;
ans = max(ans, f[i] + maxb);
}
cout << ans << endl;
return 0;
}