var input=`
5
abaaaaaaaa
oneplustwo
aaaaaaaaba
twoplusone
aaaabaaaaa
`;
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n").reverse();
var n=arr.pop()-0;
var s=arr.map(v=> v.split("").sort().join(""));
s.sort();
var sum=0;
var cnt=1;
s.reduce((a,b)=>{
   if(a==b)cnt++;
   else {
      sum+=(cnt*(cnt-1))/2;     
      cnt=1;
   }
   return b;
});
sum+=(cnt*(cnt-1))/2;
console.log(sum);