from collections import defaultdict



n=int(eval(input()))

dct=defaultdict(int)



for i in range(n):

  s=eval(input())

  sort_s="".join(sorted(s))

  dct[sort_s]+=1

ans=0

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

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

print(ans)
import sys

input = sys.stdin.buffer.readline



#sys.setrecursionlimit(10**9)

#from functools import lru_cache



def RD(): return input().rstrip().decode()

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

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

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

def MF(): return list(map(float,input().split()))

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

def LF(): return list(map(float,input().split()))

def TI(): return tuple(map(int,input().split()))

# rstrip().decode()



from collections import defaultdict



def main():

	n=II()

	d=defaultdict(int)

	for _ in range(n):

		s=list(RD())

		s.sort()

		d[tuple(s)]+=1



	ans=0



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

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

	print(ans)



















if __name__ == "__main__":

	main()

from collections import defaultdict

n = int(eval(input()))
dct = defaultdict(int)
for i in range(n):
    s = eval(input())
    sort_s = "".join(sorted(s))
    dct[sort_s] += 1
ans = 0
for k, v in list(dct.items()):
    ans += v * (v - 1) // 2
print(ans)

import sys

input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**9)
# from functools import lru_cache
def RD():
    return input().rstrip().decode()


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


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


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


def MF():
    return list(map(float, input().split()))


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


def LF():
    return list(map(float, input().split()))


def TI():
    return tuple(map(int, input().split()))


# rstrip().decode()
from collections import defaultdict


def main():
    n = II()
    d = defaultdict(int)
    for _ in range(n):
        s = list(RD())
        s.sort()
        d[tuple(s)] += 1
    ans = 0
    for _, v in list(d.items()):
        ans += (v * (v - 1)) // 2
    print(ans)


if __name__ == "__main__":
    main()

+import sys + +input = sys.stdin.buffer.readline +# sys.setrecursionlimit(10**9) +# from functools import lru_cache +def RD(): +    return input().rstrip().decode() + + +def II(): +    return int(eval(input())) + + +def FI(): +    return int(eval(input())) + + +def MI(): +    return list(map(int, input().split())) + + +def MF(): +    return list(map(float, input().split())) + + +def LI(): +    return list(map(int, input().split())) + + +def LF(): +    return list(map(float, input().split())) + + +def TI(): +    return tuple(map(int, input().split())) + + +# rstrip().decode() -n = int(eval(input())) -dct = defaultdict(int) -for i in range(n): -    s = eval(input()) -    sort_s = "".join(sorted(s)) -    dct[sort_s] += 1 -ans = 0 -for k, v in list(dct.items()): -    ans += v * (v - 1) // 2 -print(ans) + +def main(): +    n = II() +    d = defaultdict(int) +    for _ in range(n): +        s = list(RD()) +        s.sort() +        d[tuple(s)] += 1 +    ans = 0 +    for _, v in list(d.items()): +        ans += (v * (v - 1)) // 2 +    print(ans) + + +if __name__ == "__main__": +    main()