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

function getCharData(stringArray) {
  let base = {};
  for (let i = 0; i < stringArray.length; i++) {
    if (!base.hasOwnProperty(stringArray[i])) {
      base[stringArray[i]] = 1;
    } else {
      base[stringArray[i]] += 1;
    }
  }
  return base;
}

function isSame(array1, array2) {
  let keys = Object.keys(array1);
  for (let key of keys) {
    if (array1[key] !== array2[key]) {
      return false;
    }
  }
  return true;
}

function main(input) {
  input = input.split("\n");
  const stringNum = parseInt(input.shift());
  let result = [];
  for (let i = 0; i < stringNum; i++) {
    result.push(getCharData(input.shift().split("")));
  }

  let max = 0;
  for (let i = 0; i < stringNum; i++) {
    for (let f = i + 1; f < stringNum; f++) {
      if (isSame(result[i], result[f])) {
        max++;
      }
    }
  }
  console.log(max);
}
