function Main(input) {
  lines = input.split('\n')
  N = lines.shift() * 1
  ans = 0
  d = {}
  for (i=0; i<N; i++) {
      l = lines[i].split('').sort().join('')
      if (!d[l]) {
          d[l] = 1
      } else {
          d[l] += 1
      }
  }
  k = Object.keys(d)
  for (i=0; i<k.length; i++) {
      if (d[k[i]] > 1) {
          j = d[k[i]] - 1
          while (j > 0) {
              ans += j
              j--
          }
      } 
  }
  console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))