N = int(eval(input()))

D = {}

for _ in range(N):

    s = eval(input())

    r = ''.join(sorted([c for c in s]))

    if r in D:

        D[r] += 1

    else:

        D[r] = 1

ans = 0

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

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

print(ans)

import sys

from collections import Counter



n, *S = sys.stdin.read().split()

n = int(n)



def main():

    t = [''.join(sorted(t)) for t in S]

    c = Counter(t)

    cnt = 0

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

        cnt += v*(v-1)

    print((cnt//2))



main()

N = int(eval(input()))
D = {}
for _ in range(N):
    s = eval(input())
    r = "".join(sorted([c for c in s]))
    if r in D:
        D[r] += 1
    else:
        D[r] = 1
ans = 0
for v in list(D.values()):
    ans += v * (v - 1) // 2
print(ans)

import sys
from collections import Counter

n, *S = sys.stdin.read().split()
n = int(n)


def main():
    t = ["".join(sorted(t)) for t in S]
    c = Counter(t)
    cnt = 0
    for v in list(c.values()):
        cnt += v * (v - 1)
    print((cnt // 2))


main()

-N = int(eval(input())) -D = {} -for _ in range(N): -    s = eval(input()) -    r = "".join(sorted([c for c in s])) -    if r in D: -        D[r] += 1 -    else: -        D[r] = 1 -ans = 0 -for v in list(D.values()): -    ans += v * (v - 1) // 2 -print(ans) +import sys +from collections import Counter + +n, *S = sys.stdin.read().split() +n = int(n) + + +def main(): +    t = ["".join(sorted(t)) for t in S] +    c = Counter(t) +    cnt = 0 +    for v in list(c.values()): +        cnt += v * (v - 1) +    print((cnt // 2)) + + +main()