from collections import defaultdict

from math import factorial

if __name__ == "__main__":

    n = int(eval(input()))

    lst = []

    count = 0

    words = defaultdict(lambda: 0)

    for i in range(n):

        words[''.join(sorted(eval(input())))] += 1

    sum = 0

    for word in words:

        sum += int(factorial(words[word]) / (factorial(2) * factorial(abs(words[word] - 2))))

    print(sum)

from collections import defaultdict



if __name__ == "__main__":

    n = int(eval(input()))

    lst = []

    count = 0

    words = defaultdict(lambda: 0)

    for i in range(n):

        words[''.join(sorted(eval(input())))] += 1

    sum = 0

    for word in words:

        sum += int(words[word]*(words[word] - 1)/2)

    print(sum)

from collections import defaultdict
from math import factorial

if __name__ == "__main__":
    n = int(eval(input()))
    lst = []
    count = 0
    words = defaultdict(lambda: 0)
    for i in range(n):
        words["".join(sorted(eval(input())))] += 1
    sum = 0
    for word in words:
        sum += int(
            factorial(words[word]) / (factorial(2) * factorial(abs(words[word] - 2)))
        )
    print(sum)

from collections import defaultdict

if __name__ == "__main__":
    n = int(eval(input()))
    lst = []
    count = 0
    words = defaultdict(lambda: 0)
    for i in range(n):
        words["".join(sorted(eval(input())))] += 1
    sum = 0
    for word in words:
        sum += int(words[word] * (words[word] - 1) / 2)
    print(sum)

-from math import factorial -        sum += int( -            factorial(words[word]) / (factorial(2) * factorial(abs(words[word] - 2))) -        ) +        sum += int(words[word] * (words[word] - 1) / 2)