import collections

from math import ceil

import math



def combinations_count(n, r):

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





n = int(eval(input()))

x = []

for i in range(n):

	s = list(eval(input()))

	s.sort()

	z = (' '.join(map(str, s)))

	x.append(z)

c = collections.Counter(x)



ans = 0

for y in list(c.values()):

	if y > 1:

		ans += combinations_count(y,2)

print(ans)
import collections

from math import factorial

import math

def combinations_count(n, r):

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



n =int(eval(input()))

s_lis = []



for i in range(n):

	x = list(eval(input()))

	x.sort()

	n = ''.join(x)

	s_lis.append(n)



z = collections.Counter(s_lis)



ans = 0

for i in list(z.values()):

	if i>1:

		ans += combinations_count(i, 2)

print(ans)
import collections
from math import ceil
import math


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


n = int(eval(input()))
x = []
for i in range(n):
    s = list(eval(input()))
    s.sort()
    z = " ".join(map(str, s))
    x.append(z)
c = collections.Counter(x)
ans = 0
for y in list(c.values()):
    if y > 1:
        ans += combinations_count(y, 2)
print(ans)

import collections
from math import factorial
import math


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


n = int(eval(input()))
s_lis = []
for i in range(n):
    x = list(eval(input()))
    x.sort()
    n = "".join(x)
    s_lis.append(n)
z = collections.Counter(s_lis)
ans = 0
for i in list(z.values()):
    if i > 1:
        ans += combinations_count(i, 2)
print(ans)

-from math import ceil +from math import factorial -x = [] +s_lis = [] -    s = list(eval(input())) -    s.sort() -    z = " ".join(map(str, s)) -    x.append(z) -c = collections.Counter(x) +    x = list(eval(input())) +    x.sort() +    n = "".join(x) +    s_lis.append(n) +z = collections.Counter(s_lis) -for y in list(c.values()): -    if y > 1: -        ans += combinations_count(y, 2) +for i in list(z.values()): +    if i > 1: +        ans += combinations_count(i, 2)