from collections import Counter

n = int(eval(input()))

t = Counter([''.join(sorted(eval(input()))) for _ in range(n)])

print((sum(t[k] * (t[k] -1) // 2 for k in t)))

def main():

  from collections import Counter

  from sys import stdin

  readline = stdin.readline

  N = int(readline())

  t = Counter([''.join(sorted(readline()[:-1])) for _ in range(N)])

  print((sum(t[k] * (t[k] - 1) // 2 for k in t)))

main()

from collections import Counter

n = int(eval(input()))
t = Counter(["".join(sorted(eval(input()))) for _ in range(n)])
print((sum(t[k] * (t[k] - 1) // 2 for k in t)))

def main():
    from collections import Counter
    from sys import stdin

    readline = stdin.readline
    N = int(readline())
    t = Counter(["".join(sorted(readline()[:-1])) for _ in range(N)])
    print((sum(t[k] * (t[k] - 1) // 2 for k in t)))


main()

-from collections import Counter +def main(): +    from collections import Counter +    from sys import stdin -n = int(eval(input())) -t = Counter(["".join(sorted(eval(input()))) for _ in range(n)]) -print((sum(t[k] * (t[k] - 1) // 2 for k in t))) +    readline = stdin.readline +    N = int(readline()) +    t = Counter(["".join(sorted(readline()[:-1])) for _ in range(N)]) +    print((sum(t[k] * (t[k] - 1) // 2 for k in t))) + + +main()