def slove():

    import sys, collections

    input = sys.stdin.readline

    n = int(input().rstrip('\n'))

    s = ["".join(sorted(list(str(input().rstrip('\n'))))) for _ in range(n)]

    s = collections.Counter(s).most_common()

    t = 0

    for i, v in s:

        for j in range(1, v):

            t += j

    print(t)





if __name__ == '__main__':

    slove()

def slove():

    import sys

    import collections

    input = sys.stdin.readline

    n = int(input().rstrip('\n'))

    s = collections.Counter(["".join(sorted(str(input().rstrip('\n')))) for _ in range(n)])

    t = 0

    for k, v in list(s.items()):

        for i in range(1, v):

            t += i

    print(t)





if __name__ == '__main__':

    slove()

def slove():
    import sys, collections

    input = sys.stdin.readline
    n = int(input().rstrip("\n"))
    s = ["".join(sorted(list(str(input().rstrip("\n"))))) for _ in range(n)]
    s = collections.Counter(s).most_common()
    t = 0
    for i, v in s:
        for j in range(1, v):
            t += j
    print(t)


if __name__ == "__main__":
    slove()

def slove():
    import sys
    import collections

    input = sys.stdin.readline
    n = int(input().rstrip("\n"))
    s = collections.Counter(
        ["".join(sorted(str(input().rstrip("\n")))) for _ in range(n)]
    )
    t = 0
    for k, v in list(s.items()):
        for i in range(1, v):
            t += i
    print(t)


if __name__ == "__main__":
    slove()

-    import sys, collections +    import sys +    import collections -    s = ["".join(sorted(list(str(input().rstrip("\n"))))) for _ in range(n)] -    s = collections.Counter(s).most_common() +    s = collections.Counter( +        ["".join(sorted(str(input().rstrip("\n")))) for _ in range(n)] +    ) -    for i, v in s: -        for j in range(1, v): -            t += j +    for k, v in list(s.items()): +        for i in range(1, v): +            t += i