from collections import Counter



count = Counter()

for i in range(int(eval(input()))):

	s = sorted(eval(input()))

	count[''.join(s)] += 1

	

ans = 0



for n in list(count.values()):

	if n >= 2:

		ans += (n**2 - n) // 2 

		

print(ans)
import sys



input = sys.stdin.readline



def main():

    x = {}

    N = int(eval(input()))

    

    for i in range(N):

        s = sorted(eval(input()))

        s = ''.join(s)

        if s in x: x[s] += 1

        else: x[s] = 1

    

    ans = 0

    

    for n in list(x.values()):

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

        

    print(ans)



if __name__ == '__main__':

    main()
from collections import Counter

count = Counter()
for i in range(int(eval(input()))):
    s = sorted(eval(input()))
    count["".join(s)] += 1
ans = 0
for n in list(count.values()):
    if n >= 2:
        ans += (n**2 - n) // 2
print(ans)

import sys

input = sys.stdin.readline


def main():
    x = {}
    N = int(eval(input()))
    for i in range(N):
        s = sorted(eval(input()))
        s = "".join(s)
        if s in x:
            x[s] += 1
        else:
            x[s] = 1
    ans = 0
    for n in list(x.values()):
        ans += n * (n - 1) // 2
    print(ans)


if __name__ == "__main__":
    main()

-from collections import Counter +import sys -count = Counter() -for i in range(int(eval(input()))): -    s = sorted(eval(input())) -    count["".join(s)] += 1 -ans = 0 -for n in list(count.values()): -    if n >= 2: -        ans += (n**2 - n) // 2 -print(ans) +input = sys.stdin.readline + + +def main(): +    x = {} +    N = int(eval(input())) +    for i in range(N): +        s = sorted(eval(input())) +        s = "".join(s) +        if s in x: +            x[s] += 1 +        else: +            x[s] = 1 +    ans = 0 +    for n in list(x.values()): +        ans += n * (n - 1) // 2 +    print(ans) + + +if __name__ == "__main__": +    main()