"use strict";
main(require("fs").readFileSync("/dev/stdin", "UTF-8"));

function main(input) {
  input = input.split("\n");
  const stringNum = parseInt(input.shift()); // 数量
  input = input.map(s =>
    s
      .split("")
      .sort()
      .join("")
  );
  let stringCounter = {};
  for (const str of input) {
    if (!stringCounter.hasOwnProperty(str)) {
      stringCounter[str] = 1;
    } else {
      stringCounter[str] += 1;
    }
  }
  let result = 0;
  for (let [key, count] of Object.entries(stringCounter)) {
    result += (count * (count - 1)) / 2;
  }

  console.log(result);
}