import itertools,math

n = int(eval(input()))

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

count = 0



def combinations_count(n, r):

    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))



for i in range(n):

    word[i] = sorted(word[i])



new_word = list(sorted(word))



x = 1



for i in range(n-1):

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

        x += 1

    elif x >= 2:

        count += combinations_count(x,2)

        x = 1

if x >= 2:

    count +=  combinations_count(x,2)



print(count)
#他の人の回答

import collections



N = int(eval(input()))

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

#sortedでリストになった文字列をjoinでもう一度文字列に

c = collections.Counter(s)

#cは辞書の形をとる

ans = 0



# sから重複を無くす

for si in set(s):

    n = c[si]

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

    # n C 2を計算

print(ans)

import itertools, math

n = int(eval(input()))
word = [eval(input()) for _ in range(n)]
count = 0


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(n):
    word[i] = sorted(word[i])
new_word = list(sorted(word))
x = 1
for i in range(n - 1):
    if new_word[i] == new_word[i + 1]:
        x += 1
    elif x >= 2:
        count += combinations_count(x, 2)
        x = 1
if x >= 2:
    count += combinations_count(x, 2)
print(count)

# 他の人の回答
import collections

N = int(eval(input()))
s = ["".join(sorted(eval(input()))) for _ in range(N)]
# sortedでリストになった文字列をjoinでもう一度文字列に
c = collections.Counter(s)
# cは辞書の形をとる
ans = 0
# sから重複を無くす
for si in set(s):
    n = c[si]
    ans += n * (n - 1) // 2
    # n C 2を計算
print(ans)

-import itertools, math +# 他の人の回答 +import collections -n = int(eval(input())) -word = [eval(input()) for _ in range(n)] -count = 0 - - -def combinations_count(n, r): -    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) - - -for i in range(n): -    word[i] = sorted(word[i]) -new_word = list(sorted(word)) -x = 1 -for i in range(n - 1): -    if new_word[i] == new_word[i + 1]: -        x += 1 -    elif x >= 2: -        count += combinations_count(x, 2) -        x = 1 -if x >= 2: -    count += combinations_count(x, 2) -print(count) +N = int(eval(input())) +s = ["".join(sorted(eval(input()))) for _ in range(N)] +# sortedでリストになった文字列をjoinでもう一度文字列に +c = collections.Counter(s) +# cは辞書の形をとる +ans = 0 +# sから重複を無くす +for si in set(s): +    n = c[si] +    ans += n * (n - 1) // 2 +    # n C 2を計算 +print(ans)