// ~~ icebear love attttt ~~
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
template<class T>
bool minimize(T &a, const T &b) {
if (a > b) return a = b, true;
return false;
}
template<class T>
bool maximize(T &a, const T &b) {
if (a < b) return a = b, true;
return false;
}
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for(int i=(a); i>=(b); --i)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define RED(i, n) for(int i=(n)-1; i>=0; --i)
#define MASK(i) (1LL << (i))
#define BIT(S, i) (((S) >> (i)) & 1)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define task "icebearat"
const int MOD = 1e9 + 7;
const int inf = 1e9 + 27092008;
const ll INF = 1e18 + 27092008;
const int N = 2e5 + 5;
int numStr;
string str[N];
struct Trie {
struct Node {
Node *child[26];
int cnt;
Node() {
REP(i, 26) child[i] = NULL;
cnt = 0;
}
};
Node *root;
Trie() {
root = new Node();
}
void add(string &s) {
Node *p = root;
for(char c : s) {
int pos = c - 'a';
if (p -> child[pos] == NULL) p -> child[pos] = new Node();
p = p -> child[pos];
}
p -> cnt++;
}
int query(string &s) {
int ans = 0;
Node *p = root;
for(char c : s) {
int pos = c - 'a';
p = p -> child[pos];
ans += p -> cnt;
}
return ans;
}
} trie;
void init(void) {
cin >> numStr;
FOR(i, 1, numStr) cin >> str[i];
}
void process(void) {
int ans = 0;
sort(str + 1, str + numStr + 1, [&](const string &a, const string &b){
return a.size() < b.size();
});
FOR(i, 1, numStr) {
reverse(all(str[i]));
trie.add(str[i]);
maximize(ans, trie.query(str[i]));
}
cout << ans;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
int tc = 1;
// cin >> tc;
while(tc--) {
init();
process();
}
return 0;
}
Ly8gfn4gaWNlYmVhciBsb3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A4Owpjb25zdCBsbCBJTkYgPSAxZTE4ICsgMjcwOTIwMDg7CmNvbnN0IGludCBOID0gMmU1ICsgNTsKaW50IG51bVN0cjsKc3RyaW5nIHN0cltOXTsKCnN0cnVjdCBUcmllIHsKICAgIHN0cnVjdCBOb2RlIHsKICAgICAgICBOb2RlICpjaGlsZFsyNl07CiAgICAgICAgaW50IGNudDsKICAgICAgICBOb2RlKCkgewogICAgICAgICAgICBSRVAoaSwgMjYpIGNoaWxkW2ldID0gTlVMTDsKICAgICAgICAgICAgY250ID0gMDsKICAgICAgICB9CiAgICB9OwoKICAgIE5vZGUgKnJvb3Q7CiAgICBUcmllKCkgewogICAgICAgIHJvb3QgPSBuZXcgTm9kZSgpOwogICAgfQoKICAgIHZvaWQgYWRkKHN0cmluZyAmcykgewogICAgICAgIE5vZGUgKnAgPSByb290OwogICAgICAgIGZvcihjaGFyIGMgOiBzKSB7CiAgICAgICAgICAgIGludCBwb3MgPSBjIC0gJ2EnOwogICAgICAgICAgICBpZiAocCAtPiBjaGlsZFtwb3NdID09IE5VTEwpIHAgLT4gY2hpbGRbcG9zXSA9IG5ldyBOb2RlKCk7CiAgICAgICAgICAgIHAgPSBwIC0+IGNoaWxkW3Bvc107CiAgICAgICAgfQogICAgICAgIHAgLT4gY250Kys7CiAgICB9CgogICAgaW50IHF1ZXJ5KHN0cmluZyAmcykgewogICAgICAgIGludCBhbnMgPSAwOwogICAgICAgIE5vZGUgKnAgPSByb290OwogICAgICAgIGZvcihjaGFyIGMgOiBzKSB7CiAgICAgICAgICAgIGludCBwb3MgPSBjIC0gJ2EnOwogICAgICAgICAgICBwID0gcCAtPiBjaGlsZFtwb3NdOwogICAgICAgICAgICBhbnMgKz0gcCAtPiBjbnQ7CiAgICAgICAgfQogICAgICAgIHJldHVybiBhbnM7CiAgICB9Cn0gdHJpZTsKCnZvaWQgaW5pdCh2b2lkKSB7CiAgICBjaW4gPj4gbnVtU3RyOwogICAgRk9SKGksIDEsIG51bVN0cikgY2luID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