import sys

sys.setrecursionlimit(2**31-1)

input = sys.stdin.readline

write = sys.stdout.write

LMIIS = lambda : list(map(int,input().split()))

II = lambda : int(input())

dbg = lambda *something : print(*something) if DEBUG is True else 0

DEBUG = True

def cmb(n,r):  #nCr = n!/(n-r)!r!

    retVal = 1

    for i in range(n-r+1,n+1):

        retVal *= i

    for i in range(2,r+1):

        retVal //= i

    return retVal

def main():

    from collections import defaultdict

    N = int(input())

    d = defaultdict(lambda:0)

    base = ord('a')

    ans = 0

    for _ in range(N):

        s = input().strip()

        num = 0

        for c in s:

            num += 26 ** (ord(c) - base)

        ans += d[num]

        d[num] += 1



    

    print(ans)



        



    











    pass

if __name__ == '__main__':

    main()

import sys

sys.setrecursionlimit(2**31-1)

input = sys.stdin.readline

write = sys.stdout.write

LMIIS = lambda : list(map(int,input().split()))

II = lambda : int(input())

dbg = lambda *something : print(*something) if DEBUG is True else 0

DEBUG = True

def cmb(n,r):  #nCr = n!/(n-r)!r!

    retVal = 1

    for i in range(n-r+1,n+1):

        retVal *= i

    for i in range(2,r+1):

        retVal //= i

    return retVal

def main():

    from collections import defaultdict

    N = int(input())

    d = defaultdict(lambda:0)

    base = ord('a')

    ans = 0

    for _ in range(N):

        s = input().strip() 

        s = ''.join(sorted(s))

        ans += d[s]

        d[s] += 1



    

    print(ans)



        



    











    pass

if __name__ == '__main__':

    main()

import sys

sys.setrecursionlimit(2**31 - 1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda: list(map(int, input().split()))
II = lambda: int(input())
dbg = lambda *something: print(*something) if DEBUG is True else 0
DEBUG = True


def cmb(n, r):  # nCr = n!/(n-r)!r!
    retVal = 1
    for i in range(n - r + 1, n + 1):
        retVal *= i
    for i in range(2, r + 1):
        retVal //= i
    return retVal


def main():
    from collections import defaultdict

    N = int(input())
    d = defaultdict(lambda: 0)
    base = ord("a")
    ans = 0
    for _ in range(N):
        s = input().strip()
        num = 0
        for c in s:
            num += 26 ** (ord(c) - base)
        ans += d[num]
        d[num] += 1
    print(ans)
    pass


if __name__ == "__main__":
    main()

import sys

sys.setrecursionlimit(2**31 - 1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda: list(map(int, input().split()))
II = lambda: int(input())
dbg = lambda *something: print(*something) if DEBUG is True else 0
DEBUG = True


def cmb(n, r):  # nCr = n!/(n-r)!r!
    retVal = 1
    for i in range(n - r + 1, n + 1):
        retVal *= i
    for i in range(2, r + 1):
        retVal //= i
    return retVal


def main():
    from collections import defaultdict

    N = int(input())
    d = defaultdict(lambda: 0)
    base = ord("a")
    ans = 0
    for _ in range(N):
        s = input().strip()
        s = "".join(sorted(s))
        ans += d[s]
        d[s] += 1
    print(ans)
    pass


if __name__ == "__main__":
    main()

-        num = 0 -        for c in s: -            num += 26 ** (ord(c) - base) -        ans += d[num] -        d[num] += 1 +        s = "".join(sorted(s)) +        ans += d[s] +        d[s] += 1