function isAnagram(word1,word2){
    if(word1.length!=word2.length)
        return false;
    
    var word1Array = word1.split('');
    var word2Array = word2.split('');
    
    for(var i=0;i<word1Array.length;i++){
      if (word2Array.indexOf(word1Array[i]) != -1){
        word2Array[word2Array.indexOf(word1Array[i])] = '';
      }
    }

    var check = word2Array.every(function(item){
      return item === '';
    });
    return check;
}

// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n");
  var N = Number(input[0]);
  var count = 0;
  for(var i = 1; i <= N; i++){
    for(var j = 1; j <= N; j++){
      if(j <= i) continue;
      if(isAnagram(input[i], input[j])){
        count = count + 1;
      }
    }
  }
  console.log(count);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
