function Main(input){
var s = input.split("\n");
var N =parseInt(s,10);
var count = 0;
for(i=1;i<=N;i++){
  var array = s[i].split("");
  var arraySort = array.sort();
  for(j=1;j<=N;j++){
    if(i>=j){
      continue;
    }
    var array1 = s[j].split("");
    var arraySort1 = array1.sort();
    var judge = arraySort.join("") === arraySort1.join("");
    if(judge==true){
        count += 1;
      }
    }
  } 
  console.log(count);
}
  Main(require('fs').readFileSync('/dev/stdin','utf8'));