"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;
  for(let i = 0; i < words[0]; i++){
    for(let k = i+1; k < words[0]; k++)
      if(sortWords[i]==sortWords[k]){
          count++;
      }
  }
  
  console.log(count);
}

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