from sys import stdin



readline = stdin.readline

def main():

    # _, *keys = map(lambda s: ''.join(sorted(s.rstrip())), open(0))

    _, *keys = [tuple(sorted(s)) for s in open(0)]

    primes = {}

    res = 0

    for key in keys:

        if key in primes:

            res += primes[key]

            primes[key] += 1

        else:

            primes[key] = 1

    print(res)





if __name__ == "__main__":

    main()

from sys import stdin



readline = stdin.readline

def main():

    _, *keys = [''.join(sorted(s.rstrip())) for s in open(0)]

    # _, *keys = map(lambda s: tuple(sorted(s)), open(0))

    primes = {}

    res = 0

    for key in keys:

        if key in primes:

            res += primes[key]

            primes[key] += 1

        else:

            primes[key] = 1

    print(res)





if __name__ == "__main__":

    main()

from sys import stdin

readline = stdin.readline


def main():
    # _, *keys = map(lambda s: ''.join(sorted(s.rstrip())), open(0))
    _, *keys = [tuple(sorted(s)) for s in open(0)]
    primes = {}
    res = 0
    for key in keys:
        if key in primes:
            res += primes[key]
            primes[key] += 1
        else:
            primes[key] = 1
    print(res)


if __name__ == "__main__":
    main()

from sys import stdin

readline = stdin.readline


def main():
    _, *keys = ["".join(sorted(s.rstrip())) for s in open(0)]
    # _, *keys = map(lambda s: tuple(sorted(s)), open(0))
    primes = {}
    res = 0
    for key in keys:
        if key in primes:
            res += primes[key]
            primes[key] += 1
        else:
            primes[key] = 1
    print(res)


if __name__ == "__main__":
    main()

-    # _, *keys = map(lambda s: ''.join(sorted(s.rstrip())), open(0)) -    _, *keys = [tuple(sorted(s)) for s in open(0)] +    _, *keys = ["".join(sorted(s.rstrip())) for s in open(0)] +    # _, *keys = map(lambda s: tuple(sorted(s)), open(0))