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

void main()
{
    immutable n = readln.chomp.to!size_t;
    size_t[immutable(ubyte)[]] d;
    foreach (i; 0..n)
    {
        auto s = cast(ubyte[])(readln.chomp);
        auto k = s.sort().array.idup;
        if (auto p = k in d)
            (*p)++;
        else
            d[k] = 1;
    }
    ulong answer;
    foreach (v; d.byValue)
        answer += v*(v-1)/2;
    answer.writeln;
}
