n = int(eval(input()))

words = [sorted(eval(input())) for _ in range(n)]

sorted_words = sorted(words)



result = 0

sorted_words_dup = sorted_words[:]

while sorted_words_dup:

    same_cnt = 1

    word = sorted_words_dup.pop()

    while 0 < len(sorted_words_dup) and sorted_words_dup[-1] == word:

        sorted_words_dup.pop()

        same_cnt += 1

    result += same_cnt*(same_cnt-1)//2



print(result)

import sys

from collections import defaultdict

from heapq import *

sys.setrecursionlimit(10**8)



input = sys.stdin.readline



def main():

    """ main """

    N = int(eval(input()))

    dp = {}

    ans = 0

    for _ in range(N):

        str = ''.join(sorted(input().rstrip()))

        if str in dp:

            ans += dp[str]

            dp[str] += 1

        else:

            dp[str] = 1

    print(ans)



if __name__ == '__main__':

    main()

n = int(eval(input()))
words = [sorted(eval(input())) for _ in range(n)]
sorted_words = sorted(words)
result = 0
sorted_words_dup = sorted_words[:]
while sorted_words_dup:
    same_cnt = 1
    word = sorted_words_dup.pop()
    while 0 < len(sorted_words_dup) and sorted_words_dup[-1] == word:
        sorted_words_dup.pop()
        same_cnt += 1
    result += same_cnt * (same_cnt - 1) // 2
print(result)

import sys
from collections import defaultdict
from heapq import *

sys.setrecursionlimit(10**8)
input = sys.stdin.readline


def main():
    """main"""
    N = int(eval(input()))
    dp = {}
    ans = 0
    for _ in range(N):
        str = "".join(sorted(input().rstrip()))
        if str in dp:
            ans += dp[str]
            dp[str] += 1
        else:
            dp[str] = 1
    print(ans)


if __name__ == "__main__":
    main()

-n = int(eval(input())) -words = [sorted(eval(input())) for _ in range(n)] -sorted_words = sorted(words) -result = 0 -sorted_words_dup = sorted_words[:] -while sorted_words_dup: -    same_cnt = 1 -    word = sorted_words_dup.pop() -    while 0 < len(sorted_words_dup) and sorted_words_dup[-1] == word: -        sorted_words_dup.pop() -        same_cnt += 1 -    result += same_cnt * (same_cnt - 1) // 2 -print(result) +import sys +from collections import defaultdict +from heapq import * + +sys.setrecursionlimit(10**8) +input = sys.stdin.readline + + +def main(): +    """main""" +    N = int(eval(input())) +    dp = {} +    ans = 0 +    for _ in range(N): +        str = "".join(sorted(input().rstrip())) +        if str in dp: +            ans += dp[str] +            dp[str] += 1 +        else: +            dp[str] = 1 +    print(ans) + + +if __name__ == "__main__": +    main()