var ToSource = (obj) => {
  return Object.keys(obj).sort().reduce((i,e)=>{
    return i + e + obj[e];
  },"");
};
var PairCount = (itemCount) => {
	var i = 1;
	var sum = 0;
	while(i < itemCount) { sum += i; i++; }
	return sum;
};
var input = require('fs').readFileSync('/dev/stdin', 'utf8').split("\n");
input.shift();
input = input.map((s)=>{
  var charmap = {};
  s.split("").forEach((c)=>{ 
    if (charmap[c] === undefined) charmap[c]=0;
    charmap[c] += 1; 
  }); 
  return ToSource(charmap);  
});
var counted = input.map(()=>{return 0;});
var sum = 0;
for(var i = 0; i < counted.length; i++) {
  if(counted[i] != 0) continue;
  var count = 1;
  for(var j = i+1; j < counted.length; j++) {
    if(counted[j] != 0) continue;
    if(input[i] == input[j]) {
      counted[j] = 1;
      count++;
    }
  }
  sum += PairCount(count);
}
console.log(sum);
