'use strict'

const main = (input) => {
  const args = input.split('\n');
  args.shift()
  const lines = args.map((s)=>{
    return s.split('').sort()
  })
  lines.sort().join('')
  let count = 0
  let temp = {}
  lines.forEach((s) => {
    if(temp[s]) {
      temp[s] += 1
    } else {
      temp[s] = 1
    }
  })

  Object.keys(temp).forEach((i) => {
    count += temp[i]*(temp[i]-1)/2
  })

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