'use strict'

function Main(input) {
  const N = Number(input.split("\n")[0])
  const list = input.split("\n").slice(1)

  const sorted = list.map(x => x.split("").sort().join("")).sort()

  let count = 0
  let ans = 0
  for(let i=1; i<N; i++) {
    if(sorted[i-1] === sorted[i]) {
      count++
    } else {
      ans += ((1+count)*count/2)
      count = 0
    }
  }
  ans += ((1+count)*count/2)

  console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim())