function main(input) {
  const tmp = input.trim().split('\n')
  const n = parseInt(tmp[0])

  const m = new Map()

  for (let i = 1; i <= n; i++) {
    const s = tmp[i]
    const ss = s.split('').sort().join('')

    if (m.has(ss)) {
      m.set(ss, m.get(ss) + 1)
    } else {
      m.set(ss, 1)
    }
  }

  let answer = 0
  m.forEach((v, _) => {
    answer += (v - 1) * v / 2
  })

  console.log(answer)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
