#include <iostream>
#include <vector>
#include <string>
#include <cstring>
inline int onko_harmoniset(const std::string& str0, const std::string& str1)
{
if(str0.length() != str1.length()) return 0;
unsigned char map_0[26], map_1[26];
for(int i = 0; i < 26; i++)
{
map_0[i] = 0;
map_1[i] = 0;
}
const char* str0_r = str0.c_str();
const char* str1_r = str1.c_str();
for(unsigned int i = 0; i < str0.length(); i++)
{
const unsigned char a = (str0_r[i] & 0b111111);
const unsigned char b = (str1_r[i] & 0b111111);
if((map_0[a] == 0) && (map_1[b] == 0))
{
map_0[a] = b;
map_1[b] = a;
}
else
{
if((map_0[a] != b) || (map_1[b] != a))
{
return 0;
}
}
}
return 1;
}
int main()
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(0);
int n;
std::cin >> n;
std::vector<std::string> mjt;
mjt.resize(n);
for(int i = 0; i < n; i++)
{
std::cin >> mjt[i];
}
int hn = 0;
for(unsigned int i0 = 0; i0 < mjt.size(); i0++)
{
for(unsigned int i1 = i0 + 1; i1 < mjt.size(); i1++)
{
hn += onko_harmoniset(mjt[i0], mjt[i1]);
}
}
std::cout << hn;
return 0;
}