#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <map>
#include <unordered_set>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
long long n;
cin>>n;
string arr[n];
map<string,long long> m;
for(long long i=0;i<n;i++){
cin>>arr[i];
}
for(long long i=0; i<n; i++){
map<char,vector<long long>> us;
for (long long j=0; j<arr[i].length();j++){
us[arr[i][j]].push_back(j);
}
string harmony_hash = to_string(arr[i].length())+":";
vector<vector<long long>> l;
for(auto const& it : us){
if(it.second.size()>1){
l.push_back(it.second);
}
}
sort(l.begin(), l.end());
for(int j=0;j<l.size();j++){
for(long long k=0;k<l[j].size();k++){
harmony_hash.append(to_string(l[j][k])+",");
}
harmony_hash.append(":");
}
//cout<<harmony_hash<<"\n";
++m[harmony_hash];
}
long long c=0;
for(auto const& it : m){
c=c+it.second*(it.second-1)/2;
}
cout<<c<<"\n";
}