#python3

import collections as cl

n=int(eval(input()))

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

sum=0

for i in list(cl.Counter(a).values()):

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

print(sum)









import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



from collections import Counter

def main():

    n = int(readline())

    S = []

    for i in range(n):

        S.append(''.join(sorted(readline().rstrip().decode())))

    ans = 0

    for v in list(Counter(S).values()):

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

    print(ans)

if __name__ == '__main__':

    main()

# python3
import collections as cl

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

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import Counter


def main():
    n = int(readline())
    S = []
    for i in range(n):
        S.append("".join(sorted(readline().rstrip().decode())))
    ans = 0
    for v in list(Counter(S).values()):
        ans += v * (v - 1) // 2
    print(ans)


if __name__ == "__main__":
    main()

-# python3 -import collections as cl +import sys -n = int(eval(input())) -a = ["".join(sorted(eval(input()))) for _ in range(n)] -sum = 0 -for i in list(cl.Counter(a).values()): -    sum += i * (i - 1) // 2 -print(sum) +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +from collections import Counter + + +def main(): +    n = int(readline()) +    S = [] +    for i in range(n): +        S.append("".join(sorted(readline().rstrip().decode()))) +    ans = 0 +    for v in list(Counter(S).values()): +        ans += v * (v - 1) // 2 +    print(ans) + + +if __name__ == "__main__": +    main()