import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
pragma(inline, true) void scan(Args...)(ref Args args) {
    string[] ss = readln.split;
    foreach (i, ref arg ; args) arg = ss[i].parse!int;
}

void main() {
    int n; scan(n);
    int[string] cnt;
    foreach (i; 0..n) {
        cnt[readln.chomp.dup.to!(char[]).representation.sort().to!string]++;
    }
    long ans;
    foreach (i, v ; cnt) {
        ans += (1L * v * (v-1)) / 2;
    }
    writeln(ans);
}
