def main():

	n = int(eval(input()))

	sl=[]

	for i in range(n):

		sl.append(list(eval(input())))

	for s in sl:

		s.sort()

	sl.sort()

	

	

	b=sl[0]

	l=1

	ans=0

	for i in range(1,n):

		if sl[i]==b:

			l+=1

			if i==n-1 and l >1:

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

		else:

			if l>1:

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

			b=sl[i]

			l=1

	print((int(ans)))



main()

def main():

	n = int(eval(input()))

	sl=[]

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

	sl.sort()

	b=sl[0]

	l=1

	ans=0

	for i in range(1,n):

		if sl[i]==b:

			l+=1

			if i==n-1 and l >1:

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

		else:

			if l>1:

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

			b=sl[i]

			l=1

	print((int(ans)))



main()

def main():
    n = int(eval(input()))
    sl = []
    for i in range(n):
        sl.append(list(eval(input())))
    for s in sl:
        s.sort()
    sl.sort()
    b = sl[0]
    l = 1
    ans = 0
    for i in range(1, n):
        if sl[i] == b:
            l += 1
            if i == n - 1 and l > 1:
                ans += l * (l - 1) / 2
        else:
            if l > 1:
                ans += l * (l - 1) / 2
            b = sl[i]
            l = 1
    print((int(ans)))


main()

def main():
    n = int(eval(input()))
    sl = []
    sl = ["".join(sorted(eval(input()))) for _ in range(n)]
    sl.sort()
    b = sl[0]
    l = 1
    ans = 0
    for i in range(1, n):
        if sl[i] == b:
            l += 1
            if i == n - 1 and l > 1:
                ans += l * (l - 1) / 2
        else:
            if l > 1:
                ans += l * (l - 1) / 2
            b = sl[i]
            l = 1
    print((int(ans)))


main()

-    for i in range(n): -        sl.append(list(eval(input()))) -    for s in sl: -        s.sort() +    sl = ["".join(sorted(eval(input()))) for _ in range(n)]