function main(lines) {
  console.log(solve(lines));
}

function solve(lines) {
  var hoge = parseLines(lines);
  var s = hoge.s;

  var tb = {};

  s.map(function(s) {
    return s
      .split('')
      .sort()
      .join('');
  }).forEach(function(s) {
    if (!tb[s]) tb[s] = 1;
    else tb[s] += 1;
  });

  return Object.entries(tb)
    .map(function(kv) {
      var v = kv[0];
      return (v * (v - 1)) / 2;
    })
    .reduce(function(a, c) {
      return a + c;
    }, 0)
    .toString();
}

function parseLines(lines) {
  var obj = { N: +lines[0], s: lines.slice(1) };
  return obj;
}

if (!process.env.LOCAL_DEBUG) {
  var input = process.stdin;
  var output = process.stdout;
  input.resume();
  input.setEncoding('utf8');
  var lines = [];
  require('readline')
    .createInterface({ input: input, output: output })
    .on('line', function(line) {
      lines.push(line);
    })
    .on('close', function() {
      main(lines);
    });
}
