import os,re,sys,operator

from collections import Counter,deque

from operator import itemgetter

from itertools import accumulate,combinations,groupby

from sys import stdin,setrecursionlimit

from copy import deepcopy

import heapq



setrecursionlimit(10**6)



n=int(eval(input()))

s=["".join(sorted(eval(input()))) for _ in range(n)]

t=list(Counter(s).values())

ans=0

for i in t:

    ans+=sum(range(1,i))

print(ans)
import os,re,sys,operator

from collections import Counter,deque

from operator import itemgetter

from itertools import accumulate,combinations,groupby

from sys import stdin,setrecursionlimit

from copy import deepcopy

import heapq



setrecursionlimit(10**6)



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

s=["".join(sorted(stdin.readline().rstrip())) for _ in range(n)]

t=list(Counter(s).values())

ans=0

for i in t:

    ans+=sum(range(1,i))

print(ans)
import os, re, sys, operator
from collections import Counter, deque
from operator import itemgetter
from itertools import accumulate, combinations, groupby
from sys import stdin, setrecursionlimit
from copy import deepcopy
import heapq

setrecursionlimit(10**6)
n = int(eval(input()))
s = ["".join(sorted(eval(input()))) for _ in range(n)]
t = list(Counter(s).values())
ans = 0
for i in t:
    ans += sum(range(1, i))
print(ans)

import os, re, sys, operator
from collections import Counter, deque
from operator import itemgetter
from itertools import accumulate, combinations, groupby
from sys import stdin, setrecursionlimit
from copy import deepcopy
import heapq

setrecursionlimit(10**6)
n = int(stdin.readline().rstrip())
s = ["".join(sorted(stdin.readline().rstrip())) for _ in range(n)]
t = list(Counter(s).values())
ans = 0
for i in t:
    ans += sum(range(1, i))
print(ans)

-n = int(eval(input())) -s = ["".join(sorted(eval(input()))) for _ in range(n)] +n = int(stdin.readline().rstrip()) +s = ["".join(sorted(stdin.readline().rstrip())) for _ in range(n)]