import sys

from collections import Counter, defaultdict

from math import factorial



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



def combinations_count(n, r): # 組み合わせ

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



N = ir()

S = defaultdict(int)

for _ in range(N):

    s = list(sr())

    s.sort()

    s = str(s)

    if s in S:

        S[s] += 1

    else:

        S[s] = 1



counter = Counter(S)

answer = 0

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

    if v >= 2:

        answer += combinations_count(v, 2)



print(answer)

import sys

from collections import Counter



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



N = ir()

S = [''.join(sorted(list(sr()))) for _ in range(N)]



counter = Counter(S)

answer = sum(x*(x-1)//2 for x in list(counter.values()))

print(answer)

import sys
from collections import Counter, defaultdict
from math import factorial

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))


def combinations_count(n, r):  # 組み合わせ
    return factorial(n) // (factorial(n - r) * factorial(r))


N = ir()
S = defaultdict(int)
for _ in range(N):
    s = list(sr())
    s.sort()
    s = str(s)
    if s in S:
        S[s] += 1
    else:
        S[s] = 1
counter = Counter(S)
answer = 0
for v in list(counter.values()):
    if v >= 2:
        answer += combinations_count(v, 2)
print(answer)

import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
S = ["".join(sorted(list(sr()))) for _ in range(N)]
counter = Counter(S)
answer = sum(x * (x - 1) // 2 for x in list(counter.values()))
print(answer)

-from collections import Counter, defaultdict -from math import factorial +from collections import Counter - - -def combinations_count(n, r):  # 組み合わせ -    return factorial(n) // (factorial(n - r) * factorial(r)) - - -S = defaultdict(int) -for _ in range(N): -    s = list(sr()) -    s.sort() -    s = str(s) -    if s in S: -        S[s] += 1 -    else: -        S[s] = 1 +S = ["".join(sorted(list(sr()))) for _ in range(N)] -answer = 0 -for v in list(counter.values()): -    if v >= 2: -        answer += combinations_count(v, 2) +answer = sum(x * (x - 1) // 2 for x in list(counter.values()))