n = int(eval(input()))

l = [str(sorted(str(eval(input())))) for _ in range(n)]



d = {}



for i in range(n):

  s = l[i]

  # print(s)

  if s in d:

    d[s] += 1

  else:

    d[s] = 1



ans = 0

for x in list(d.values()):

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

print((int(ans)))





import sys

sys.setrecursionlimit(10**9)

input = sys.stdin.readline



n = int(eval(input()))

l = [str(sorted(str(eval(input())))) for _ in range(n)]

 

d = {}

 

for i in range(n):

  s = l[i]

  # print(s)

  if s in d:

    d[s] += 1

  else:

    d[s] = 1



ans = 0

for x in list(d.values()):

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

print((int(ans)))
n = int(eval(input()))
l = [str(sorted(str(eval(input())))) for _ in range(n)]
d = {}
for i in range(n):
    s = l[i]
    # print(s)
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
ans = 0
for x in list(d.values()):
    ans += x * (x - 1) / 2
print((int(ans)))

import sys

sys.setrecursionlimit(10**9)
input = sys.stdin.readline
n = int(eval(input()))
l = [str(sorted(str(eval(input())))) for _ in range(n)]
d = {}
for i in range(n):
    s = l[i]
    # print(s)
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
ans = 0
for x in list(d.values()):
    ans += x * (x - 1) / 2
print((int(ans)))

+import sys + +sys.setrecursionlimit(10**9) +input = sys.stdin.readline