from collections import Counter





def main():

    n = int(eval(input()))

    anas = Counter(''.join(sorted(eval(input()))) for _ in range(n))



    result = sum(sum(range(anas[a])) for a in anas)

    print(result)





main()
from collections import Counter

from sys import stdin





def main():

    n = int(eval(input()))

    anas = Counter(''.join(sorted(stdin.readline())) for _ in range(n))



    result = sum(sum(range(anas[a])) for a in anas)

    print(result)





main()

from collections import Counter


def main():
    n = int(eval(input()))
    anas = Counter("".join(sorted(eval(input()))) for _ in range(n))
    result = sum(sum(range(anas[a])) for a in anas)
    print(result)


main()

from collections import Counter
from sys import stdin


def main():
    n = int(eval(input()))
    anas = Counter("".join(sorted(stdin.readline())) for _ in range(n))
    result = sum(sum(range(anas[a])) for a in anas)
    print(result)


main()

+from sys import stdin -    anas = Counter("".join(sorted(eval(input()))) for _ in range(n)) +    anas = Counter("".join(sorted(stdin.readline())) for _ in range(n))