# import bisect

# import copy

# import fractions

# import math

# import numpy as np

from collections import Counter

# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product



def resolve():

    N=int(eval(input()))

    S=[''.join(sorted(eval(input()))) for i in range(N)]

    C=Counter(S)

    print((sum([i*(i-1)//2 for i in list(C.values())])))













resolve()

from collections import Counter, deque, OrderedDict

# from copy import copy, deepcopy

# from functools import reduce

# from heapq import heapify, heappop, heappush

# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

# import math

# import numpy as np  # Pythonのみ！

# from operator import xor

# import re

# from scipy.sparse.csgraph import connected_components  # Pythonのみ！

# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/

# from scipy.sparse import csr_matrix

# import string

import sys

sys.setrecursionlimit(10 ** 5 + 10)





def input(): return sys.stdin.readline().strip()





def resolve():



    n = int(eval(input()))

    d = [''.join(sorted(list(eval(input())))) for _ in range(n)]

    dd=Counter(d)

    cnt=0

    for i in list(dd.values()):

        cnt += i*(i-1)//2

    print(cnt)









resolve()
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
from collections import Counter

# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
def resolve():
    N = int(eval(input()))
    S = ["".join(sorted(eval(input()))) for i in range(N)]
    C = Counter(S)
    print((sum([i * (i - 1) // 2 for i in list(C.values())])))


resolve()

from collections import Counter, deque, OrderedDict

# from copy import copy, deepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys

sys.setrecursionlimit(10**5 + 10)


def input():
    return sys.stdin.readline().strip()


def resolve():
    n = int(eval(input()))
    d = ["".join(sorted(list(eval(input())))) for _ in range(n)]
    dd = Counter(d)
    cnt = 0
    for i in list(dd.values()):
        cnt += i * (i - 1) // 2
    print(cnt)


resolve()

-# import bisect -# import copy -# import fractions +from collections import Counter, deque, OrderedDict + +# from copy import copy, deepcopy +# from functools import reduce +# from heapq import heapify, heappop, heappush +# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product -# import numpy as np -from collections import Counter +# import numpy as np  # Pythonのみ！ +# from operator import xor +# import re +# from scipy.sparse.csgraph import connected_components  # Pythonのみ！ +# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/ +# from scipy.sparse import csr_matrix +# import string +import sys -# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product +sys.setrecursionlimit(10**5 + 10) + + +def input(): +    return sys.stdin.readline().strip() + + -    N = int(eval(input())) -    S = ["".join(sorted(eval(input()))) for i in range(N)] -    C = Counter(S) -    print((sum([i * (i - 1) // 2 for i in list(C.values())]))) +    n = int(eval(input())) +    d = ["".join(sorted(list(eval(input())))) for _ in range(n)] +    dd = Counter(d) +    cnt = 0 +    for i in list(dd.values()): +        cnt += i * (i - 1) // 2 +    print(cnt)