2021-10-02 06:51:39 +00:00
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2021-10-02 07:05:59 +00:00
|
|
|
int n, p = 1, trie[10000005][26], size[10000005];
|
|
|
|
char s[4000005];
|
2021-10-02 06:51:39 +00:00
|
|
|
|
2021-10-02 07:05:59 +00:00
|
|
|
void insert(int u, const char* s) {
|
|
|
|
if (!strlen(s)) {
|
|
|
|
size[u] = 1;
|
2021-10-02 06:51:39 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-10-02 07:05:59 +00:00
|
|
|
if (!trie[u][s[0] - 'a']) trie[u][s[0] - 'a'] = ++p;
|
|
|
|
insert(trie[u][s[0] - 'a'], s + 1);
|
2021-10-02 06:51:39 +00:00
|
|
|
}
|
|
|
|
|
2021-10-02 07:05:59 +00:00
|
|
|
void calcsize(int u) {
|
2021-10-02 06:51:39 +00:00
|
|
|
for (int i = 0; i < 26; i++) {
|
2021-10-02 07:05:59 +00:00
|
|
|
if (trie[u][i]) {
|
|
|
|
calcsize(trie[u][i]);
|
|
|
|
size[u] += size[trie[u][i]];
|
2021-10-02 06:51:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
std::ios::sync_with_stdio(false);
|
2021-10-02 07:05:59 +00:00
|
|
|
scanf("%d", &n);
|
|
|
|
for (int i = 1; i <= n; i++) {
|
|
|
|
scanf("%s", s);
|
|
|
|
insert(1, s);
|
2021-10-02 06:51:39 +00:00
|
|
|
}
|
2021-10-02 07:05:59 +00:00
|
|
|
calcsize(1);
|
|
|
|
printf("%d\n", size[1]);
|
2021-10-02 06:51:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|