from collections import Counter

# バージョン0.14.0まで scipy.misc.comb()

# バージョン0.14.0から scipy.special.comb()

from scipy.misc import comb

# from scipy.special import comb





def main():

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

    ans = 0

    for v in list(s.values()):

        ans += comb(v, 2, exact=True)

    print((int(ans)))

    return





main()

from collections import defaultdict





def main():

    s = ["".join(sorted(i)) for i 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()

from collections import Counter

# バージョン0.14.0まで scipy.misc.comb()
# バージョン0.14.0から scipy.special.comb()
from scipy.misc import comb

# from scipy.special import comb
def main():
    s = Counter(["".join(sorted(i)) for i in open(0).read().split()[1:]])
    ans = 0
    for v in list(s.values()):
        ans += comb(v, 2, exact=True)
    print((int(ans)))
    return


main()

from collections import defaultdict


def main():
    s = ["".join(sorted(i)) for i 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()

-from collections import Counter +from collections import defaultdict -# バージョン0.14.0まで scipy.misc.comb() -# バージョン0.14.0から scipy.special.comb() -from scipy.misc import comb -# from scipy.special import comb -    s = Counter(["".join(sorted(i)) for i in open(0).read().split()[1:]]) +    s = ["".join(sorted(i)) for i in open(0).read().split()[1:]] +    d = defaultdict(lambda: 0) -    for v in list(s.values()): -        ans += comb(v, 2, exact=True) -    print((int(ans))) +    for i in s: +        ans += d[i] +        d[i] += 1 +    print(ans)