'use strict';(function(input){
  
  input=input.trim().split(/\n+/);
  const N=input.shift();
  input=input.map(str=>str.split('').sort().join(''));
  
  const counter={};
  for(let i=0;i<N;i++){
    if(!counter.hasOwnProperty(input[i])){
      counter[input[i]]=1;
    }else{
      counter[input[i]]++;
    }
  }
  
  var ans=0;
  
  for(let str in counter){
    let n=counter[str];
    ans+=n*(n-1)/2;
  }
  
  
  console.log(ans);
})(require('fs').readFileSync('/dev/stdin','utf8'));
