#include <iostream>
#include <unordered_map>
#include <string>
using namespace std;
long long fact(long n)
{
long long res = 1;
for (long i = 2; i <= n; i++)
res = res * i;
return res;
}
long long nCr(long n, long r)
{
return fact(n) / (fact(r) * fact(n - r));
}
long main() {
long n;
cin >> n;
string strings[n];
for(long i = 0; i < n; i++) {
cin >> strings[i];
}
unordered_map<string,long> total;
for(long i = 0; i < n; i++) {
unordered_map<char, long> used;
for(long j = 0; j < strings[i].length(); j++) {
if(used.count(strings[i][j])) {
strings[i][j] = used[strings[i][j]];
} else {
used[strings[i][j]] = (char)j;
strings[i][j] = (char)j;
}
}
if(total.count(strings[i])) {
total[strings[i]]++;
} else {
total[strings[i]] = 1;
}
}
long long pairs = 0;
for(pair<string,long> entry : total) {
pairs += nCr(entry.second,2);
//cout << entry.first << ": " << entry.second << endl;
}
cout << pairs;
return 0;
}