function main (arg) {
	arg = arg.trim().split('\n');
  	var n = Number(arg.shift()),
        s = arg, cnt = 0, out = [];
	//文字列を昇順にする為の配列処理
	s = s.map(str => str.split(''));
    for (var i = 0; i < n; i++) {
      var str = s[i].sort().join('');
      //console.log(i+1+'週目', '【'+str+'】', '配列に'+out[str])
        if(out[str]) {
            cnt += out[str];
            out[str]++;
        } else {
            out[str] = 1;
        }
    }
  console.log(cnt)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));