# coding: utf-8

# Your code here!

N = int(eval(input()))



sd = {}

ans = 0



for _ in range(N):

    inp = eval(input())

    si = ''.join(sorted(inp))

    

    if not si in sd:

        sd[si] = 1

    else:

        ans += sd[si]

        sd[si] += 1



print(ans)

# coding: utf-8

import sys

input = sys.stdin.readline



def main():

    N = int(eval(input()))

    sd = {}

    ans = 0

    for _ in range(N):

        si = ''.join(sorted(input().strip()))

        if not si in sd:

            sd[si] = 1

        else:

            ans += sd[si]

            sd[si] += 1

    print(ans)

    

if __name__ == '__main__':

    main()
# coding: utf-8
# Your code here!
N = int(eval(input()))
sd = {}
ans = 0
for _ in range(N):
    inp = eval(input())
    si = "".join(sorted(inp))
    if not si in sd:
        sd[si] = 1
    else:
        ans += sd[si]
        sd[si] += 1
print(ans)

# coding: utf-8
import sys

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    sd = {}
    ans = 0
    for _ in range(N):
        si = "".join(sorted(input().strip()))
        if not si in sd:
            sd[si] = 1
        else:
            ans += sd[si]
            sd[si] += 1
    print(ans)


if __name__ == "__main__":
    main()

-# Your code here! -N = int(eval(input())) -sd = {} -ans = 0 -for _ in range(N): -    inp = eval(input()) -    si = "".join(sorted(inp)) -    if not si in sd: -        sd[si] = 1 -    else: -        ans += sd[si] -        sd[si] += 1 -print(ans) +import sys + +input = sys.stdin.readline + + +def main(): +    N = int(eval(input())) +    sd = {} +    ans = 0 +    for _ in range(N): +        si = "".join(sorted(input().strip())) +        if not si in sd: +            sd[si] = 1 +        else: +            ans += sd[si] +            sd[si] += 1 +    print(ans) + + +if __name__ == "__main__": +    main()