import sys,math,itertools

def r(x):

    sum = 0

    for i in range(1,x+1):

        sum += i

    return sum



N = int(eval(input()))

s = []

ans = [0] * N

for i in range(N):

    tmp = eval(input())

    li_tmp = list(tmp)

    s_tmp = sorted(li_tmp)

    st = "".join(s_tmp)

    s.append(st)



data = {}

a = set()

a.add(s[N-1])

for i in range(N-2,-1,-1):

    if s[i] in a:

        if s[i] in data:

            data[s[i]] += 1

        else:

            data[s[i]] = 1 

    else:

        a.add(s[i])

for i in data:

    data[i] = r(data[i])

print((sum(data.values())))
import sys,math,collections

N = int(eval(input()))

s = []

ans = 0

for i in range(N):

    li_tmp = list(eval(input()))

    li_tmp.sort()

    st = "".join(li_tmp)

    s.append(st)

cnt = collections.Counter(s)

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

    if i != 1:

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

print(ans)
import sys, math, itertools


def r(x):
    sum = 0
    for i in range(1, x + 1):
        sum += i
    return sum


N = int(eval(input()))
s = []
ans = [0] * N
for i in range(N):
    tmp = eval(input())
    li_tmp = list(tmp)
    s_tmp = sorted(li_tmp)
    st = "".join(s_tmp)
    s.append(st)
data = {}
a = set()
a.add(s[N - 1])
for i in range(N - 2, -1, -1):
    if s[i] in a:
        if s[i] in data:
            data[s[i]] += 1
        else:
            data[s[i]] = 1
    else:
        a.add(s[i])
for i in data:
    data[i] = r(data[i])
print((sum(data.values())))

import sys, math, collections

N = int(eval(input()))
s = []
ans = 0
for i in range(N):
    li_tmp = list(eval(input()))
    li_tmp.sort()
    st = "".join(li_tmp)
    s.append(st)
cnt = collections.Counter(s)
for i in list(cnt.values()):
    if i != 1:
        ans += i * (i - 1) // 2
print(ans)

-import sys, math, itertools - - -def r(x): -    sum = 0 -    for i in range(1, x + 1): -        sum += i -    return sum - +import sys, math, collections -ans = [0] * N +ans = 0 -    tmp = eval(input()) -    li_tmp = list(tmp) -    s_tmp = sorted(li_tmp) -    st = "".join(s_tmp) +    li_tmp = list(eval(input())) +    li_tmp.sort() +    st = "".join(li_tmp) -data = {} -a = set() -a.add(s[N - 1]) -for i in range(N - 2, -1, -1): -    if s[i] in a: -        if s[i] in data: -            data[s[i]] += 1 -        else: -            data[s[i]] = 1 -    else: -        a.add(s[i]) -for i in data: -    data[i] = r(data[i]) -print((sum(data.values()))) +cnt = collections.Counter(s) +for i in list(cnt.values()): +    if i != 1: +        ans += i * (i - 1) // 2 +print(ans)