# ABC137C - Green Bin

from collections import Counter





def main():

    N = int(eval(input()))

    A = Counter("".join(sorted(eval(input()))) for _ in range(N))

    ans = sum(i * (i - 1) // 2 for i in list(A.values()))

    print(ans)





if __name__ == "__main__":

    main()
# ABC137C - Green Bin

import sys

input = sys.stdin.readline



from collections import Counter





def main():

    N = int(eval(input()))

    A = Counter("".join(sorted(eval(input()))) for _ in range(N))

    ans = sum(i * (i - 1) // 2 for i in list(A.values()))

    print(ans)





if __name__ == "__main__":

    main()
# ABC137C - Green Bin
from collections import Counter


def main():
    N = int(eval(input()))
    A = Counter("".join(sorted(eval(input()))) for _ in range(N))
    ans = sum(i * (i - 1) // 2 for i in list(A.values()))
    print(ans)


if __name__ == "__main__":
    main()

# ABC137C - Green Bin
import sys

input = sys.stdin.readline
from collections import Counter


def main():
    N = int(eval(input()))
    A = Counter("".join(sorted(eval(input()))) for _ in range(N))
    ans = sum(i * (i - 1) // 2 for i in list(A.values()))
    print(ans)


if __name__ == "__main__":
    main()

+import sys + +input = sys.stdin.readline