import sys

from operator import mul

from functools import reduce



def combinations_count(n, r):

    r = min(r, n - r)

    numer = reduce(mul, list(range(n, n - r, -1)), 1)

    denom = reduce(mul, list(range(1, r + 1)), 1)

    return numer // denom



def main():

    N = int(eval(input()))



    Ss = {}

    for x in range(N):

        tmp = ''.join(sorted(eval(input())))



        if tmp in Ss:

            Ss[tmp] += 1



        else:

            Ss[tmp] = 1





    ans = 0

    for i in list(Ss.values()):

        if i != 1:

            ans += combinations_count(i, 2)



    print(ans)



main()
import sys

from operator import mul

from functools import reduce



def combinations_count(n, r):

    r = min(r, n - r)

    numer = reduce(mul, list(range(n, n - r, -1)), 1)

    denom = reduce(mul, list(range(1, r + 1)), 1)

    return numer // denom



def main():

    N = int(eval(input()))



    Ss = {}

    for x in range(N):

        tmp = ''.join(sorted(sys.stdin.readline().rstrip()))



        if tmp in Ss:

            Ss[tmp] += 1



        else:

            Ss[tmp] = 1





    ans = 0

    for i in list(Ss.values()):

        if i != 1:

            ans += combinations_count(i, 2)



    print(ans)



main()
import sys
from operator import mul
from functools import reduce


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, list(range(n, n - r, -1)), 1)
    denom = reduce(mul, list(range(1, r + 1)), 1)
    return numer // denom


def main():
    N = int(eval(input()))
    Ss = {}
    for x in range(N):
        tmp = "".join(sorted(eval(input())))
        if tmp in Ss:
            Ss[tmp] += 1
        else:
            Ss[tmp] = 1
    ans = 0
    for i in list(Ss.values()):
        if i != 1:
            ans += combinations_count(i, 2)
    print(ans)


main()

import sys
from operator import mul
from functools import reduce


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, list(range(n, n - r, -1)), 1)
    denom = reduce(mul, list(range(1, r + 1)), 1)
    return numer // denom


def main():
    N = int(eval(input()))
    Ss = {}
    for x in range(N):
        tmp = "".join(sorted(sys.stdin.readline().rstrip()))
        if tmp in Ss:
            Ss[tmp] += 1
        else:
            Ss[tmp] = 1
    ans = 0
    for i in list(Ss.values()):
        if i != 1:
            ans += combinations_count(i, 2)
    print(ans)


main()

-        tmp = "".join(sorted(eval(input()))) +        tmp = "".join(sorted(sys.stdin.readline().rstrip()))