function main(input) {
  const args = input.split('\n');
  const nums = args[0]
  var objs = []
  var count = 0;
  for(var i = 1;i <= nums; i++){
    var str = args[i]
    var obj = {}
    for(var j = 0;j < str.length;j++){
      var letter = str[j]
      if(obj[letter] == null) {
        obj[letter] = 1
      } else {
        obj[letter] += 1
      }
    }
    objs.push(obj)
  }
  
  function equalObj(obj1, obj2){
    for(var key in obj1) {
      if(obj1[key] !== obj2[key]) {
        return false
      }
    }
    return true
  }
  
  for(var i = 0;i < nums; i++){
    for(var j = i + 1;j < nums; j++){
      if(equalObj(objs[i], objs[j])){
        count++
      }
    } 
  }
  console.log(count)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));