var input = require('fs').readFileSync('/dev/stdin', 'utf8').split("\n");
input.shift();
input = input.map((s)=>{
  return s.split("").sort().join("");
});
var countmap = {};

for(var i = 0; i < input.length; i++) {
	var s = input[i];
	if (countmap[s] === undefined) countmap[s] = [0,0];
	else {
		countmap[s][0] += 1;
		countmap[s][1] += countmap[s][0];
	}
}
console.log(Object.keys(countmap).reduce((i,e)=>{return i+countmap[e][1];},0));
