'use strict'

function main(input) {
  const lines = input.split('\n');
  lines.pop();
  const n = lines.shift();
  f(lines);
}

function f(lines) {
  const parsed = {}
  lines.forEach(line => {
    const sorted = line.split('').sort().join('');
    if (!!parsed[sorted]) {
      parsed[sorted] += 1;
    } else {
      parsed[sorted] = 1;
    }
  });
  let result = 0;
  Object.keys(parsed).forEach(k => {
    const v = parsed[k];
    if (v === 2) {
      result += 1;
    } else if (v > 2) {
      result += (v * (v - 1)) / 2;
    }
  });
  console.log(result);
}

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