'use strict'

const countChar = (string) => {
  const stringChar = string.split('')
  const result = {}
  let lengthCount = 0
  stringChar.forEach((c) => {
    if(result[c]>=1){
      reuslt[c] = result[c] + 1
    } else {
      result[c] = 1
      lengthCount++
    }
  })
  result['length'] = lengthCount

  let keys = Object.keys(result).sort
  let newMap = {}
  keys.forEach((i) => {
    newMap[i] = result[i]
  })

  return newMap
}

const main = (input) => {
  const args = input.split('\n');

  let N = 0
  const data = []
  let count = 0
  args.forEach((s,i) => {
    if(i === 0) {
      N = s
    } else {
      const head = countChar(s)

      data.forEach((ds)=>{
        if(ds['length'] === head['length'] &&
          JSON.stringify(ds)===JSON.stringify(head)
        ){
          count++
        }
      })
      data.push(countChar(s))
    }
  })

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