import collections

def main4():

    n = int(eval(input()))

    l = []

    for i in range(n):

        s = eval(input())

        l.append((sorted(s)))

    l.sort()

    dd = collections.defaultdict(int)

    k = []

    for i in range(n):

        k.append(''.join(l[i]))

    res = 0

    for i in range(n):

        dd[k[i]]+=1

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

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

    print(res)



if __name__ == '__main__':

    main4()

import collections

def main4():

    dd = collections.defaultdict(int)

    n = int(eval(input()))

    res = 0

    for i in range(n):

        s = eval(input())

        a = sorted(s)

        dd[''.join(a)]+=1

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

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

    print(res)





if __name__ == '__main__':

    main4()
import collections


def main4():
    n = int(eval(input()))
    l = []
    for i in range(n):
        s = eval(input())
        l.append((sorted(s)))
    l.sort()
    dd = collections.defaultdict(int)
    k = []
    for i in range(n):
        k.append("".join(l[i]))
    res = 0
    for i in range(n):
        dd[k[i]] += 1
    for i in list(dd.values()):
        res += (i * (i - 1)) // 2
    print(res)


if __name__ == "__main__":
    main4()

import collections


def main4():
    dd = collections.defaultdict(int)
    n = int(eval(input()))
    res = 0
    for i in range(n):
        s = eval(input())
        a = sorted(s)
        dd["".join(a)] += 1
    for i in list(dd.values()):
        res += (i * (i - 1)) // 2
    print(res)


if __name__ == "__main__":
    main4()

+    dd = collections.defaultdict(int) -    l = [] +    res = 0 -        l.append((sorted(s))) -    l.sort() -    dd = collections.defaultdict(int) -    k = [] -    for i in range(n): -        k.append("".join(l[i])) -    res = 0 -    for i in range(n): -        dd[k[i]] += 1 +        a = sorted(s) +        dd["".join(a)] += 1