import sys

from collections import defaultdict



read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines

sys.setrecursionlimit(10 ** 9)

INF = 1 << 60

MOD = 1000000007





def main():

    N = int(readline())

    S = [0] * N

    for i in range(N):

        S[i] = readline().strip()



    d = defaultdict(int)

    for s in S:

        c = [0] * 26

        for l in s:

            c[ord(l) - 97] += 1

        d[tuple(c)] += 1



    ans = 0

    for n in list(d.values()):

        if n > 1:

            ans += n * (n - 1) // 2



    print(ans)

    return





if __name__ == '__main__':

    main()

import sys

from collections import defaultdict



read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines

sys.setrecursionlimit(10 ** 9)

INF = 1 << 60

MOD = 1000000007





def main():

    N = int(readline())

    S = [0] * N

    for i in range(N):

        S[i] = readline().strip()



    d = defaultdict(int)

    for s in S:

        d[''.join(sorted(s))] += 1



    ans = 0

    for n in list(d.values()):

        if n > 1:

            ans += n * (n - 1) // 2



    print(ans)

    return





if __name__ == '__main__':

    main()

import sys
from collections import defaultdict

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = [0] * N
    for i in range(N):
        S[i] = readline().strip()
    d = defaultdict(int)
    for s in S:
        c = [0] * 26
        for l in s:
            c[ord(l) - 97] += 1
        d[tuple(c)] += 1
    ans = 0
    for n in list(d.values()):
        if n > 1:
            ans += n * (n - 1) // 2
    print(ans)
    return


if __name__ == "__main__":
    main()

import sys
from collections import defaultdict

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = [0] * N
    for i in range(N):
        S[i] = readline().strip()
    d = defaultdict(int)
    for s in S:
        d["".join(sorted(s))] += 1
    ans = 0
    for n in list(d.values()):
        if n > 1:
            ans += n * (n - 1) // 2
    print(ans)
    return


if __name__ == "__main__":
    main()

-        c = [0] * 26 -        for l in s: -            c[ord(l) - 97] += 1 -        d[tuple(c)] += 1 +        d["".join(sorted(s))] += 1