import sys

input = sys.stdin.readline

import math

import collections

def I(): return int(eval(input()))

def MI(): return list(map(int, input().split()))

def LI(): return list(map(int, input().split()))



n=I()

strs=[]

for i in range(n):

    line=sorted(input().rstrip())

    STR=""

    for j in line:

        STR=STR+j

    strs.append(STR)

#print(strs)

x=collections.Counter(strs)

#print(x)

sm=0

for j in x:

    sm+=x[j]*(x[j]-1)//2

print(sm)
import sys

input = sys.stdin.readline

sys.setrecursionlimit(10**7)

from collections import Counter, deque

from collections import defaultdict

from itertools import combinations, permutations, accumulate, groupby, product

from bisect import bisect_left,bisect_right

from heapq import heapify, heappop, heappush

from math import floor, ceil

from operator import itemgetter

def I(): return int(eval(input()))

def MI(): return list(map(int, input().split()))

def LI(): return list(map(int, input().split()))

def LI2(): return [int(eval(input())) for i in range(n)]

def MXI(): return [[LI()]for i in range(n)]

def printns(x): print(('\n'.join(x)))

def printni(x): print(('\n'.join(list(map(str,x)))))

inf = 10**17

mod = 10**9 + 7

#s=input().rstrip()

n=I()

lis=["".join(sorted(list(input().rstrip()))) for i in range(n)]

c=Counter(lis)

#print(c)

ans=0

for j in c:

    ans+=(c[j]*(c[j]-1))//2

print(ans)
import sys

input = sys.stdin.readline
import math
import collections


def I():
    return int(eval(input()))


def MI():
    return list(map(int, input().split()))


def LI():
    return list(map(int, input().split()))


n = I()
strs = []
for i in range(n):
    line = sorted(input().rstrip())
    STR = ""
    for j in line:
        STR = STR + j
    strs.append(STR)
# print(strs)
x = collections.Counter(strs)
# print(x)
sm = 0
for j in x:
    sm += x[j] * (x[j] - 1) // 2
print(sm)

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left, bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter


def I():
    return int(eval(input()))


def MI():
    return list(map(int, input().split()))


def LI():
    return list(map(int, input().split()))


def LI2():
    return [int(eval(input())) for i in range(n)]


def MXI():
    return [[LI()] for i in range(n)]


def printns(x):
    print(("\n".join(x)))


def printni(x):
    print(("\n".join(list(map(str, x)))))


inf = 10**17
mod = 10**9 + 7
# s=input().rstrip()
n = I()
lis = ["".join(sorted(list(input().rstrip()))) for i in range(n)]
c = Counter(lis)
# print(c)
ans = 0
for j in c:
    ans += (c[j] * (c[j] - 1)) // 2
print(ans)

-import math -import collections +sys.setrecursionlimit(10**7) +from collections import Counter, deque +from collections import defaultdict +from itertools import combinations, permutations, accumulate, groupby, product +from bisect import bisect_left, bisect_right +from heapq import heapify, heappop, heappush +from math import floor, ceil +from operator import itemgetter +def LI2(): +    return [int(eval(input())) for i in range(n)] + + +def MXI(): +    return [[LI()] for i in range(n)] + + +def printns(x): +    print(("\n".join(x))) + + +def printni(x): +    print(("\n".join(list(map(str, x))))) + + +inf = 10**17 +mod = 10**9 + 7 +# s=input().rstrip() -strs = [] -for i in range(n): -    line = sorted(input().rstrip()) -    STR = "" -    for j in line: -        STR = STR + j -    strs.append(STR) -# print(strs) -x = collections.Counter(strs) -# print(x) -sm = 0 -for j in x: -    sm += x[j] * (x[j] - 1) // 2 -print(sm) +lis = ["".join(sorted(list(input().rstrip()))) for i in range(n)] +c = Counter(lis) +# print(c) +ans = 0 +for j in c: +    ans += (c[j] * (c[j] - 1)) // 2 +print(ans)