import sys

input = sys.stdin.readline



n = int(eval(input()))

ans = 0

used_s = {}

for _ in range(n):

    s = "".join(sorted(eval(input())))

    if not s in list(used_s.keys()):

        used_s[s] = 0

    else:

        used_s[s] += 1

        ans += 1 * used_s[s]



print(ans)
def main():

    import sys

    input = sys.stdin.readline



    n = int(eval(input()))

    ans = 0

    used_s = {}

    for _ in range(n):

        s = "".join(sorted(eval(input())))

        if not s in list(used_s.keys()):

            used_s[s] = 0

        else:

            used_s[s] += 1

            ans += 1 * used_s[s]



    print(ans)



if __name__ == '__main__':

    main()
import sys

input = sys.stdin.readline
n = int(eval(input()))
ans = 0
used_s = {}
for _ in range(n):
    s = "".join(sorted(eval(input())))
    if not s in list(used_s.keys()):
        used_s[s] = 0
    else:
        used_s[s] += 1
        ans += 1 * used_s[s]
print(ans)

def main():
    import sys

    input = sys.stdin.readline
    n = int(eval(input()))
    ans = 0
    used_s = {}
    for _ in range(n):
        s = "".join(sorted(eval(input())))
        if not s in list(used_s.keys()):
            used_s[s] = 0
        else:
            used_s[s] += 1
            ans += 1 * used_s[s]
    print(ans)


if __name__ == "__main__":
    main()

-import sys +def main(): +    import sys -input = sys.stdin.readline -n = int(eval(input())) -ans = 0 -used_s = {} -for _ in range(n): -    s = "".join(sorted(eval(input()))) -    if not s in list(used_s.keys()): -        used_s[s] = 0 -    else: -        used_s[s] += 1 -        ans += 1 * used_s[s] -print(ans) +    input = sys.stdin.readline +    n = int(eval(input())) +    ans = 0 +    used_s = {} +    for _ in range(n): +        s = "".join(sorted(eval(input()))) +        if not s in list(used_s.keys()): +            used_s[s] = 0 +        else: +            used_s[s] += 1 +            ans += 1 * used_s[s] +    print(ans) + + +if __name__ == "__main__": +    main()