from collections import Counter

from operator import mul

from functools import reduce





def cmb(n,r):

    r = min(n-r,r)

    if r == 0: return 1

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

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

    return over // under





N = int(eval(input()))

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

lst_s.sort()



cnt_s = Counter(lst_s)



ans = 0

for v in list(cnt_s.values()):

    if v == 1:

        continue

    else:

        ans += cmb(v, 2)

print(ans)

from collections import Counter

from operator import mul

from functools import reduce





def cmb(n,r):

    r = min(n-r,r)

    if r == 0: return 1

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

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

    return over // under





N = int(eval(input()))

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



cnt_s = Counter(lst_s)



ans = 0

for v in list(cnt_s.values()):

    if v == 1:

        continue

    else:

        ans += cmb(v, 2)

print(ans)

from collections import Counter
from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, list(range(n, n - r, -1)))
    under = reduce(mul, list(range(1, r + 1)))
    return over // under


N = int(eval(input()))
lst_s = ["".join(sorted(eval(input()))) for _ in range(N)]
lst_s.sort()
cnt_s = Counter(lst_s)
ans = 0
for v in list(cnt_s.values()):
    if v == 1:
        continue
    else:
        ans += cmb(v, 2)
print(ans)

from collections import Counter
from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, list(range(n, n - r, -1)))
    under = reduce(mul, list(range(1, r + 1)))
    return over // under


N = int(eval(input()))
lst_s = ["".join(sorted(eval(input()))) for _ in range(N)]
cnt_s = Counter(lst_s)
ans = 0
for v in list(cnt_s.values()):
    if v == 1:
        continue
    else:
        ans += cmb(v, 2)
print(ans)

-lst_s.sort()