import math

n = int(eval(input()))



dic = {}





def twoKimuawaseSum(num):

    result = 0

    for i in range(1, num):

        result += i

    return result





for i in range(n):

    string = eval(input())

    sortStr = "".join(sorted(string))

    if sortStr in dic:

        dic[sortStr] += 1

    else:

        dic[sortStr] = 1

sum = 0

for num in list(dic.values()):

    if num == 1:

        sum += 0

    else:

        sum += twoKimuawaseSum(num)

print((math.floor(sum)))

import itertools

import math

from scipy.misc import comb

n = int(eval(input()))



dic = {}

for i in range(n):

    string = eval(input())

    sortStr = "".join(sorted(string))

    if sortStr in dic:

        dic[sortStr] += 1

    else:

        dic[sortStr] = 1

sum = 0

for num in list(dic.values()):

    if num == 1:

        sum += 0

    else:

        sum += comb(num, 2,exact=True)

print((math.floor(sum)))

import math

n = int(eval(input()))
dic = {}


def twoKimuawaseSum(num):
    result = 0
    for i in range(1, num):
        result += i
    return result


for i in range(n):
    string = eval(input())
    sortStr = "".join(sorted(string))
    if sortStr in dic:
        dic[sortStr] += 1
    else:
        dic[sortStr] = 1
sum = 0
for num in list(dic.values()):
    if num == 1:
        sum += 0
    else:
        sum += twoKimuawaseSum(num)
print((math.floor(sum)))

import itertools
import math
from scipy.misc import comb

n = int(eval(input()))
dic = {}
for i in range(n):
    string = eval(input())
    sortStr = "".join(sorted(string))
    if sortStr in dic:
        dic[sortStr] += 1
    else:
        dic[sortStr] = 1
sum = 0
for num in list(dic.values()):
    if num == 1:
        sum += 0
    else:
        sum += comb(num, 2, exact=True)
print((math.floor(sum)))

+import itertools +from scipy.misc import comb - - -def twoKimuawaseSum(num): -    result = 0 -    for i in range(1, num): -        result += i -    return result - - -        sum += twoKimuawaseSum(num) +        sum += comb(num, 2, exact=True)