#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <iterator>
#include <unordered_map>
#include <stdio.h>
#include <string.h>
using namespace std;
const string alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
char alphabetArr[54];
/*
bool isPair(const string a = 0, const string b = 0) {
std::unordered_map<char, char> mapA;
std::unordered_map<char, char> mapB;
std::unordered_map<char, char>::iterator it;
char arrA[50];
char arrB[50];
string newA;
string newB;
strcpy(arrA, a.c_str());
strcpy(arrB, b.c_str());
for (int i = 0; i < (int)a.size(); i++) {
if (mapA.find(arrA[i]) != mapA.end()) {
newA = newA + std::string(1, mapA.find(arrA[i])->second);
}
else {
newA = newA + std::string(1, alphabetArr[(int)mapA.size()]);
mapA.insert(std::pair<char, char>(arrA[i], alphabetArr[(int)mapA.size()]));
}
}
for (int i = 0; i < (int)b.size(); i++) {
if (mapB.find(arrB[i]) != mapB.end()) {
newB = newB + std::string(1, mapB.find(arrB[i])->second);
}
else {
newB = newB + std::string(1, alphabetArr[(int)mapB.size()]);
mapB.insert(std::pair<char, char>(arrB[i], alphabetArr[(int)mapB.size()]));
}
}
return (newA == newB);
}
*/
string toFormat(const string in) {
std::unordered_map<char, char> mapStr;
std::unordered_map<char, char>::iterator it;
char arrStr[50];
string newStr;
strcpy(arrStr, in.c_str());
for (int i = 0; i < (int)in.size(); i++) {
if (mapStr.find(arrStr[i]) != mapStr.end()) {
newStr = newStr + std::string(1, mapStr.find(arrStr[i])->second);
}
else {
newStr = newStr + std::string(1, alphabetArr[(int)mapStr.size()]);
mapStr.insert(std::pair<char, char>(arrStr[i], alphabetArr[(int)mapStr.size()]));
}
}
return newStr;
}
int main() {
int num;
int amount = 0;
strcpy(alphabetArr, alphabet.c_str());
string arr[10000];
string newArr[10000];
std::unordered_map<string, int> CountSame;
cin >> num;
for (int i = 0; i < num; i++) {
cin >> arr[i];
}
for (int i = 0; i < num; i++) {
newArr[i] = toFormat(arr[i]);
if (CountSame.find(newArr[i]) != CountSame.end()) {
CountSame[newArr[i]] = CountSame.find(newArr[i])->second+1;
}
else {
CountSame[newArr[i]] = 1;
}
};
for (std::unordered_map<string, int>::iterator it = CountSame.begin(); it != CountSame.end(); ++it)
{
amount += (it->second * (it->second - 1))/2;
}
cout << amount;
return 0;
}