"use strict";
const main = arg => {
  let words = arg.split("\n");
  let sortWords = words.map(t => t.split("").sort().join(''));
  sortWords.splice(0, 1);
  let count = 0;
  let wordObj = {};
  for(let i = 0; i < words[0]; i++){
  if(isNaN(wordObj[sortWords[i]])){
    wordObj[sortWords[i]] = 1;
    }else {
        wordObj[sortWords[i]]++;        
    }
  }
  for(let num in wordObj){
  if(wordObj[num] > 1){
    count += wordObj[num]*(wordObj[num]-1)/2;
    }
  }
  console.log(count);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
