from collections import defaultdict





def main():

    s = ["".join(sorted(x)) for x in open(0).read().split()[1:]]

    d = defaultdict(lambda: 0)

    ans = 0

    for i in s:

        ans += d[i]

        d[i] += 1

    print(ans)

    return





main()

def main():

    s = ["".join(sorted(i)) for i in open(0).read().split()[1:]]

    ans = 0

    d = {}

    for i in s:

        if i in d:

            ans += d[i]

            d[i] += 1

        else:

            d[i] = 1

    print(ans)

    return





main()

from collections import defaultdict


def main():
    s = ["".join(sorted(x)) for x in open(0).read().split()[1:]]
    d = defaultdict(lambda: 0)
    ans = 0
    for i in s:
        ans += d[i]
        d[i] += 1
    print(ans)
    return


main()

def main():
    s = ["".join(sorted(i)) for i in open(0).read().split()[1:]]
    ans = 0
    d = {}
    for i in s:
        if i in d:
            ans += d[i]
            d[i] += 1
        else:
            d[i] = 1
    print(ans)
    return


main()

-from collections import defaultdict - - -    s = ["".join(sorted(x)) for x in open(0).read().split()[1:]] -    d = defaultdict(lambda: 0) +    s = ["".join(sorted(i)) for i in open(0).read().split()[1:]] +    d = {} -        ans += d[i] -        d[i] += 1 +        if i in d: +            ans += d[i] +            d[i] += 1 +        else: +            d[i] = 1