'use strict';
const main = input => {
  const n = parseInt(input[0], 10);
  input.shift();
  input.pop();
  let s = new Array(n);
  s = input;
  s = s.map(val => [...val].sort((x,y)=>x>y?1:-1).toString()).sort();
  // console.log(s);
  let t = s[0], val = 0, ans = 0;
  for(let i=1; i<n; i++) {
    if (s[i] == t) val++;
    else {
      ans += val*(val+1)/2;
      val = 0;
      t = s[i];
    }
  }
  if (val) ans += val*(val+1)/2;
  console.log(ans);
  
};
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));