import sys

import math





inint = lambda: int(sys.stdin.readline())

inintm = lambda: list(map(int, sys.stdin.readline().split()))

inintl = lambda: list(inintm())

instrm = lambda: list(map(str, sys.stdin.readline().split()))

instrl = lambda: list(instrm())



n = inint()



z = {():0}

ans = 0



def combinations(n, r):

    if n < r:

        return 0

    else:

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



for i in range(n):

    c = [0]*123

    s = eval(input())

    for j in range(len(s)):

        c[ord(s[j])] += 1

    try:

        z[tuple(c)] += 1

    except:

        z[tuple(c)] = 1



for i in z:

    ans += combinations(z[i],2)



print(ans)
import sys

import math





inint = lambda: int(sys.stdin.readline())

inintm = lambda: list(map(int, sys.stdin.readline().split()))

inintl = lambda: list(inintm())

instrm = lambda: list(map(str, sys.stdin.readline().split()))

instrl = lambda: list(instrm())



n = inint()



z = {}

ans = 0



for i in range(n):

    s = "".join(sorted(eval(input())))

    try:

        z[s] += 1

    except:

        z[s] = 1



for i in z:

    ans += z[i]*(z[i]-1)//2



print(ans)
import sys
import math

inint = lambda: int(sys.stdin.readline())
inintm = lambda: list(map(int, sys.stdin.readline().split()))
inintl = lambda: list(inintm())
instrm = lambda: list(map(str, sys.stdin.readline().split()))
instrl = lambda: list(instrm())
n = inint()
z = {(): 0}
ans = 0


def combinations(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(n):
    c = [0] * 123
    s = eval(input())
    for j in range(len(s)):
        c[ord(s[j])] += 1
    try:
        z[tuple(c)] += 1
    except:
        z[tuple(c)] = 1
for i in z:
    ans += combinations(z[i], 2)
print(ans)

import sys
import math

inint = lambda: int(sys.stdin.readline())
inintm = lambda: list(map(int, sys.stdin.readline().split()))
inintl = lambda: list(inintm())
instrm = lambda: list(map(str, sys.stdin.readline().split()))
instrl = lambda: list(instrm())
n = inint()
z = {}
ans = 0
for i in range(n):
    s = "".join(sorted(eval(input())))
    try:
        z[s] += 1
    except:
        z[s] = 1
for i in z:
    ans += z[i] * (z[i] - 1) // 2
print(ans)

-z = {(): 0} +z = {} - - -def combinations(n, r): -    if n < r: -        return 0 -    else: -        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) - - -    c = [0] * 123 -    s = eval(input()) -    for j in range(len(s)): -        c[ord(s[j])] += 1 +    s = "".join(sorted(eval(input()))) -        z[tuple(c)] += 1 +        z[s] += 1 -        z[tuple(c)] = 1 +        z[s] = 1 -    ans += combinations(z[i], 2) +    ans += z[i] * (z[i] - 1) // 2