from collections import defaultdict



n = int(eval(input()))

s = [eval(input()) for _ in range(n)]

cnt = defaultdict(int)

for si in s:

    cnt["".join(sorted(si))] += 1

ans = 0

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

    ans += sum(range(1, v))

print(ans)
from collections import defaultdict

import sys

def input() -> str:

    return sys.stdin.readline()

n = int(eval(input()))

s = [eval(input()) for _ in range(n)]

cnt = defaultdict(int)

for si in s:

    cnt["".join(sorted(si))] += 1

ans = 0

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

    ans += sum(range(1, v))

print(ans)

from collections import defaultdict

n = int(eval(input()))
s = [eval(input()) for _ in range(n)]
cnt = defaultdict(int)
for si in s:
    cnt["".join(sorted(si))] += 1
ans = 0
for v in list(cnt.values()):
    ans += sum(range(1, v))
print(ans)

from collections import defaultdict
import sys


def input() -> str:
    return sys.stdin.readline()


n = int(eval(input()))
s = [eval(input()) for _ in range(n)]
cnt = defaultdict(int)
for si in s:
    cnt["".join(sorted(si))] += 1
ans = 0
for v in list(cnt.values()):
    ans += sum(range(1, v))
print(ans)

+import sys + + +def input() -> str: +    return sys.stdin.readline() +