from collections import defaultdict



n = int(eval(input()))

d = defaultdict(int)

ans = 0

for _ in range(n):

    s = eval(input())

    s = str(sorted(s))

    ans += d[s]

    d[s] += 1



print(ans)

def main():

    from collections import defaultdict

    import sys

    input = sys.stdin.readline



    N = int(eval(input()))



    d = defaultdict(int)



    def string_sort(s):

        return ''.join(sorted(s))



    ans = 0

    for _ in range(N):

        s = string_sort(input().rstrip())

        ans += d[s]

        d[s] += 1

    print(ans)





if __name__ == '__main__':

    main()



# import sys

#

# sys.setrecursionlimit(10 ** 7)

#

# input = sys.stdin.readline

# rstrip()

# int(input())

# map(int, input().split())

from collections import defaultdict

n = int(eval(input()))
d = defaultdict(int)
ans = 0
for _ in range(n):
    s = eval(input())
    s = str(sorted(s))
    ans += d[s]
    d[s] += 1
print(ans)

def main():
    from collections import defaultdict
    import sys

    input = sys.stdin.readline
    N = int(eval(input()))
    d = defaultdict(int)

    def string_sort(s):
        return "".join(sorted(s))

    ans = 0
    for _ in range(N):
        s = string_sort(input().rstrip())
        ans += d[s]
        d[s] += 1
    print(ans)


if __name__ == "__main__":
    main()
# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())

-from collections import defaultdict +def main(): +    from collections import defaultdict +    import sys -n = int(eval(input())) -d = defaultdict(int) -ans = 0 -for _ in range(n): -    s = eval(input()) -    s = str(sorted(s)) -    ans += d[s] -    d[s] += 1 -print(ans) +    input = sys.stdin.readline +    N = int(eval(input())) +    d = defaultdict(int) + +    def string_sort(s): +        return "".join(sorted(s)) + +    ans = 0 +    for _ in range(N): +        s = string_sort(input().rstrip()) +        ans += d[s] +        d[s] += 1 +    print(ans) + + +if __name__ == "__main__": +    main() +# import sys +# +# sys.setrecursionlimit(10 ** 7) +# +# input = sys.stdin.readline +# rstrip() +# int(input()) +# map(int, input().split())