function Main(input){ 
  var N = input.split("\n")[0];
  var s = input.split("\n");
  s.shift();
  var a = [];
  var b = [];
  var count = 0;
  for(i=0;i<=(N-1);i++){
    a = s[i].trim().split("").sort();
    for(j=0;j<=(N-1);j++){
      b = s[j].trim().split("").sort();
      if(i>=j){
        continue;
      }else{
        for(k=0;k<=9;k++){
           var t = a[k] == b[k];
          if(t == false){
            break;
          }
          if(k==9&&t==true){
            count += 1;
          }
        }
      }
    }
  }
  console.log(count);

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