#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef unsigned long long ull;
int n;
ull myhash(string s){
ull code = 0, x = 131, y = 140814840257324663;
for(int i = 0; i < s.size(); i++){
code = (code * x + (ull)s[i]) % y;
}
return code;
}
void solve(){
ull a[10010], ans, n;
string s;
cin >> n;
for(int i = 0; i < n; i++){
cin >> s;
a[i] = myhash(s);
}
sort(a, a + n);
ans = unique(a, a + n) - a;
cout << ans << endl;
}
void solve1(){
ull a = 0xffffffffffffffff;
a = a / 131 - 131;
cout << a << endl;
while(1){
int f = 0;
for(ull i = 2; i <= a / i; i++){
if(a % i == 0){
f = 1;
break;
}
}
if(!f){
cout << a << endl;
return;
}
a--;
}
}
signed main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
solve();
return 0;
}
P3405 [USACO16DEC] Cities and States S
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
map<pair<int, int>, int>mp;
int myhash(string s){
int code = 0;
for(int i = 0; i < 2; i++){
code = code * 26 + (s[i] - 'A');
}
return code;
}
void solve(){
int ans = 0, x, y;
string s, c;
cin >> n;
for(int i = 0; i < n; i++){
cin >> c >> s;
x = myhash(c);
y = myhash(s);
if(x == y)continue;
mp[{x, y}]++;
ans += mp[{y, x}];
}
cout << ans << endl;
}
signed main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
solve();
return 0;
}