from sys import stdin

from math import factorial



def combinations_count(n, r):

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



n = int(stdin.readline().rstrip())

li = [list(stdin.readline().rstrip()) for _ in range(n)]



set_list = {}



for i in li:

    i.sort()

    s = "".join(i)

    if s in set_list:

        set_list[s] += 1

    else:

        set_list[s] = 1



point = 0



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

    if i >= 2:

        point += combinations_count(i,2)



print(point)
from sys import stdin



n = int(stdin.readline().rstrip())

li = [list(stdin.readline().rstrip()) for _ in range(n)]



set_list = {}



for i in li:

    i.sort()

    s = "".join(i)

    if s in set_list:

        set_list[s] += 1

    else:

        set_list[s] = 1



point = 0



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

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



print(point)
from sys import stdin
from math import factorial


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


n = int(stdin.readline().rstrip())
li = [list(stdin.readline().rstrip()) for _ in range(n)]
set_list = {}
for i in li:
    i.sort()
    s = "".join(i)
    if s in set_list:
        set_list[s] += 1
    else:
        set_list[s] = 1
point = 0
for i in list(set_list.values()):
    if i >= 2:
        point += combinations_count(i, 2)
print(point)

from sys import stdin

n = int(stdin.readline().rstrip())
li = [list(stdin.readline().rstrip()) for _ in range(n)]
set_list = {}
for i in li:
    i.sort()
    s = "".join(i)
    if s in set_list:
        set_list[s] += 1
    else:
        set_list[s] = 1
point = 0
for i in list(set_list.values()):
    point += i * (i - 1) // 2
print(point)

-from math import factorial - - -def combinations_count(n, r): -    return factorial(n) // (factorial(n - r) * factorial(r)) - -    if i >= 2: -        point += combinations_count(i, 2) +    point += i * (i - 1) // 2