n = int(eval(input()))



s = []

for i in range(n):

    tmp = []

    tmp = list(eval(input()))

    tmp.sort()

    s.append("".join(tmp))



s.sort()



cnt = 0

t_cnt = 0

for i in range(n-1):

    if s[i] == s[i+1]:

        t_cnt += 1

    elif s[i] != s[i+1]:

        if t_cnt > 1:

            t_cnt += 1



            t = 0

            for j in range(t_cnt):

                t += j



            cnt += t

            t_cnt = 0

        else:

            cnt += t_cnt

            t_cnt = 0



    if i == n-2:



        if t_cnt > 1:

            t_cnt += 1



            t = 0

            for j in range(t_cnt):

                t += j



            cnt += t

            t_cnt = 0

        else:

            cnt += t_cnt

            t_cnt = 0



print(cnt)

from collections import Counter



n = int(eval(input()))

s = list(Counter(["".join(sorted(eval(input()))) for _ in [0]*n]).values())



cnt = 0



for i in s:

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



print(cnt)

n = int(eval(input()))
s = []
for i in range(n):
    tmp = []
    tmp = list(eval(input()))
    tmp.sort()
    s.append("".join(tmp))
s.sort()
cnt = 0
t_cnt = 0
for i in range(n - 1):
    if s[i] == s[i + 1]:
        t_cnt += 1
    elif s[i] != s[i + 1]:
        if t_cnt > 1:
            t_cnt += 1
            t = 0
            for j in range(t_cnt):
                t += j
            cnt += t
            t_cnt = 0
        else:
            cnt += t_cnt
            t_cnt = 0
    if i == n - 2:
        if t_cnt > 1:
            t_cnt += 1
            t = 0
            for j in range(t_cnt):
                t += j
            cnt += t
            t_cnt = 0
        else:
            cnt += t_cnt
            t_cnt = 0
print(cnt)

from collections import Counter

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

+from collections import Counter + -s = [] -for i in range(n): -    tmp = [] -    tmp = list(eval(input())) -    tmp.sort() -    s.append("".join(tmp)) -s.sort() +s = list(Counter(["".join(sorted(eval(input()))) for _ in [0] * n]).values()) -t_cnt = 0 -for i in range(n - 1): -    if s[i] == s[i + 1]: -        t_cnt += 1 -    elif s[i] != s[i + 1]: -        if t_cnt > 1: -            t_cnt += 1 -            t = 0 -            for j in range(t_cnt): -                t += j -            cnt += t -            t_cnt = 0 -        else: -            cnt += t_cnt -            t_cnt = 0 -    if i == n - 2: -        if t_cnt > 1: -            t_cnt += 1 -            t = 0 -            for j in range(t_cnt): -                t += j -            cnt += t -            t_cnt = 0 -        else: -            cnt += t_cnt -            t_cnt = 0 +for i in s: +    cnt += i * (i - 1) // 2