const rowList = require('fs').readFileSync('/dev/stdin','utf8').trim().split('\n')

var stringList = rowList.slice(1).map(e => e.split('').sort().join(''))

var pairs = 0

for(;;) {
  var size = stringList.length
  var string = stringList[0]
  stringList = stringList.filter(e => e !== string)
  var sizeAfter = stringList.length
  var diff = size - sizeAfter

  var f = 0
  for(var i=1;i<diff;i++) {
    f += i
  }

  pairs += f

  if(sizeAfter <= 1) break
}

console.log(pairs)

