function Main(input) {
  var output = 0;
  var list = [];
  var list2 = [];
  
  for(var i = 1; i <= parseInt(input.split("\n")[0]); i++){
    list.push(input.split("\n")[i]);
    list2.push(input.split("\n")[i]);
  }
  for(var i = 0; i < list.length; i++){
    for(var j = i + 1; j < list2.length; j++){
      var text1 = list[i];
      var text2 = list2[j];
      var charList1 = {};
      var charList2 = {};
      
    var alphaList = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
    for(var k = 0; k < text1.length; k++){
      var tmp1 = text1.slice(k, k + 1);
      var tmp2 = text2.slice(k, k + 1);
      
      if(charList1[tmp1] != null){
        charList1[tmp1]++;
      }else{
        charList1[tmp1] = 1;
      }
      if(charList2[tmp2] != null){
        charList2[tmp2]++;
      }else{
        charList2[tmp2] = 1;
      }
    }
      
    var flag = true;
      
    for(var k = 0; k < alphaList.length; k++){
      if(charList1[alphaList[k]] == null && charList2[alphaList[k]] == null){
         continue;
      }else{
        if(charList1[alphaList[k]] != charList2[alphaList[k]]){
           flag = false;
        }
      }
    }
      if(flag){
         output++;
         }
    }
  }
  console.log(output);
  
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
