from operator import mul

from functools import reduce

import collections





def cmb(n, r):

    r = min(n - r, r)

    if r == 0:

        return 1

    elif r < 0:

        return 0

    numer = reduce(mul, list(range(n, n - r, -1)))

    denom = reduce(mul, list(range(1, r + 1)))

    return numer // denom





N = int(eval(input()))

s = ["".join(sorted(eval(input()))) for _ in range(N)]

c = collections.Counter(s)

ans = 0

for si in set(s):

    n = c[si]

    ans += cmb(n, 2)

print(ans)

import collections



N = int(eval(input()))

s = ["".join(sorted(eval(input()))) for _ in range(N)]

c = collections.Counter(s)

ans = 0

for si in set(s):

    n = c[si]

    ans += n * (n - 1) // 2

print(ans)

from operator import mul
from functools import reduce
import collections


def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    elif r < 0:
        return 0
    numer = reduce(mul, list(range(n, n - r, -1)))
    denom = reduce(mul, list(range(1, r + 1)))
    return numer // denom


N = int(eval(input()))
s = ["".join(sorted(eval(input()))) for _ in range(N)]
c = collections.Counter(s)
ans = 0
for si in set(s):
    n = c[si]
    ans += cmb(n, 2)
print(ans)

import collections

N = int(eval(input()))
s = ["".join(sorted(eval(input()))) for _ in range(N)]
c = collections.Counter(s)
ans = 0
for si in set(s):
    n = c[si]
    ans += n * (n - 1) // 2
print(ans)

-from operator import mul -from functools import reduce - - -def cmb(n, r): -    r = min(n - r, r) -    if r == 0: -        return 1 -    elif r < 0: -        return 0 -    numer = reduce(mul, list(range(n, n - r, -1))) -    denom = reduce(mul, list(range(1, r + 1))) -    return numer // denom - -    ans += cmb(n, 2) +    ans += n * (n - 1) // 2