from collections import Counter

from math import factorial

n = int(eval(input()))

s = [''.join(sorted(list(eval(input())))) for _ in range(n)]



def combination(i):

    return factorial(i) // (factorial(i-2) * factorial(2))



cnt = Counter(s)

ans = 0

for i in list(cnt.values()):

    if i == 1:

        pass

    else:

        ans += combination(i)

print(ans)
from collections import Counter

from math import factorial

n = int(eval(input()))

s = [''.join(sorted(list(eval(input())))) for _ in range(n)]



cnt = Counter(s)

ans = 0

for i in list(cnt.values()):

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

print(ans)
from collections import Counter
from math import factorial

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


def combination(i):
    return factorial(i) // (factorial(i - 2) * factorial(2))


cnt = Counter(s)
ans = 0
for i in list(cnt.values()):
    if i == 1:
        pass
    else:
        ans += combination(i)
print(ans)

from collections import Counter
from math import factorial

n = int(eval(input()))
s = ["".join(sorted(list(eval(input())))) for _ in range(n)]
cnt = Counter(s)
ans = 0
for i in list(cnt.values()):
    ans += i * (i - 1) // 2
print(ans)

- - -def combination(i): -    return factorial(i) // (factorial(i - 2) * factorial(2)) - - -    if i == 1: -        pass -    else: -        ans += combination(i) +    ans += i * (i - 1) // 2