'use strict'

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

  for(let i=0; i<N; i++) {
    const alpha = agg(list[i])
    for(let j=i+1; j<N; j++) {
      const alpha2 = agg(list[j])
      const json1 = JSON.stringify(alpha)
      const json2 = JSON.stringify(alpha2)
      if(json1 === json2) {
        ans++
      }
    }
  }

  console.log(ans)
}

function agg(str) {
  const alpha = {}
  const converted = str.split("")
  for(let i=0; i<10; i++) {
    if(alpha[converted[i]] == null) {
      alpha[converted[i]] = 0
    }
    alpha[converted[i]]++
  }
  return Object.keys(alpha).sort()
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim())