const main = (inputs) => {
  var N = inputs[0].split(" ")[0]-0;
  var map = {};
  for(var i=1;i<=N;i++){
    var ip = inputs[i].split("").sort().join("");
    if(!map[ip])map[ip] = 0;
    map[ip]++;
  }
  var ans = 0;
  Object.keys(map).forEach(key=>{
    var cnt = map[key];
    if(cnt > 1){
      ans += cnt*(cnt-1)/2;
    }
  });
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));
