import std.stdio, std.conv, std.string, std.range, std.algorithm, std.range;

void main() {
  auto N = readln.split[0].to!int;
  auto s = new string[N];
  foreach(i; 0..N) {
    s[i] = readln.split[0];
  }

  auto bucket = new int[26][N];
  foreach(i; 0..N) {
    foreach(c; s[i]) {
      bucket[i][c - 'a']++;
    }
  }

  bool compare(int[26] a, int[26] b) {
    foreach(i; 0..26) {
      if (a[i] == b[i]) continue;
      return a[i] < b[i];
    }
    return false;
  }

  bool eq(int[26] a, int[26] b) {
    foreach(i; 0..26) {
      if(a[i] != b[i])  return false;
    }
    return true;
  }

  bucket.sort!compare;

  ulong ans = 0;
  auto i = 1;
  while(i<N) {
    auto cnt = 1;
    while(i<N) {
      i++;
      if(eq(bucket[i-2], bucket[i-1])) cnt++; else break;
    }
    ans += (cnt * (cnt - 1)) / 2;
  }
  ans.writeln;
}
