from collections import defaultdict

si = lambda: eval(input())

ni = lambda: int(eval(input()))

nm = lambda: list(map(int, input().split()))

snm = lambda: list(map(str, input().split()))

nl = lambda: list(map(int, input().split()))



n=ni()

l=[]

d=defaultdict(int)

for i in range(n):

    s=list(si())

    s.sort()

    tmp=''

    for ss in s:

        tmp+=ss

    l.append(tmp)



for ll in l:

    d[ll]+=1



ans=0

for k,v in list(d.items()):

    if v>=2:

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



print(ans)
from collections import defaultdict as dd

n=int(eval(input()))

s=[]

for i in range(n):

    tmp=list(eval(input()))

    tmp.sort()

    tmp=''.join(tmp)

    s.append(tmp)



d=dd(int)

for ss in s:

    d[ss]+=1

ans=0

for k,v in list(d.items()):

    if v>=2:

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

print(ans)



from collections import defaultdict

si = lambda: eval(input())
ni = lambda: int(eval(input()))
nm = lambda: list(map(int, input().split()))
snm = lambda: list(map(str, input().split()))
nl = lambda: list(map(int, input().split()))
n = ni()
l = []
d = defaultdict(int)
for i in range(n):
    s = list(si())
    s.sort()
    tmp = ""
    for ss in s:
        tmp += ss
    l.append(tmp)
for ll in l:
    d[ll] += 1
ans = 0
for k, v in list(d.items()):
    if v >= 2:
        ans += (v * (v - 1)) // 2
print(ans)

from collections import defaultdict as dd

n = int(eval(input()))
s = []
for i in range(n):
    tmp = list(eval(input()))
    tmp.sort()
    tmp = "".join(tmp)
    s.append(tmp)
d = dd(int)
for ss in s:
    d[ss] += 1
ans = 0
for k, v in list(d.items()):
    if v >= 2:
        ans += v * (v - 1) // 2
print(ans)

-from collections import defaultdict +from collections import defaultdict as dd -si = lambda: eval(input()) -ni = lambda: int(eval(input())) -nm = lambda: list(map(int, input().split())) -snm = lambda: list(map(str, input().split())) -nl = lambda: list(map(int, input().split())) -n = ni() -l = [] -d = defaultdict(int) +n = int(eval(input())) +s = [] -    s = list(si()) -    s.sort() -    tmp = "" -    for ss in s: -        tmp += ss -    l.append(tmp) -for ll in l: -    d[ll] += 1 +    tmp = list(eval(input())) +    tmp.sort() +    tmp = "".join(tmp) +    s.append(tmp) +d = dd(int) +for ss in s: +    d[ss] += 1 -        ans += (v * (v - 1)) // 2 +        ans += v * (v - 1) // 2