#from statistics import median

#import collections

#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]

#from itertools import combinations # (string,3) 3回

#from collections import deque

#import collections.defaultdict(list)

#import bisect

#

#    d = m - k[i] - k[j]

#    if kk[bisect.bisect_right(kk,d) - 1] == d:

#

#

#

# pythonで無理なときは、pypyでやると正解するかも！！

#

#



mod = 10**9 + 7



def readInts():

  return list(map(int,input().split()))

def main():

    n = int(eval(input()))

    dic = {}

    for i in range(n):

        s = "".join(sorted(eval(input())))

        if s in dic:

            dic[s] += 1

        else:

            dic[s] = 1



    def comb(n,r,p = mod):

        r = min(r,n-r) # nCr

        res = 1

        div = 1 # nCr := n*n-1*...n-r+1 // 1*2*3...r

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

            res *= i

            res %= p

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

            div *= i

            div %= p

        res *= pow(div,p-2,p) # 掛け算に

        res %= p

        return res

    ans = 0

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

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

    print(ans)



if __name__ == '__main__':

  main()

from statistics import median

#import collections

#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]

from fractions import gcd

from itertools import combinations # (string,3) 3回

from collections import deque

from collections import defaultdict

import bisect

#

#    d = m - k[i] - k[j]

#    if kk[bisect.bisect_right(kk,d) - 1] == d:

#

#

#

# pythonで無理なときは、pypyでやると正解するかも！！

#

#



import sys

sys.setrecursionlimit(10000000)

mod = 10**9 + 7



def readInts():

  return list(map(int,input().split()))



def main():

    ana = defaultdict(int)

    n = int(eval(input()))

    for i in range(n):

        s = "".join(sorted(eval(input())))



        ana[s] += 1

    ans = 0

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

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

    print(ans)

if __name__ == '__main__':

  main()

# from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
# from itertools import combinations # (string,3) 3回
# from collections import deque
# import collections.defaultdict(list)
# import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
mod = 10**9 + 7


def readInts():
    return list(map(int, input().split()))


def main():
    n = int(eval(input()))
    dic = {}
    for i in range(n):
        s = "".join(sorted(eval(input())))
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1

    def comb(n, r, p=mod):
        r = min(r, n - r)  # nCr
        res = 1
        div = 1  # nCr := n*n-1*...n-r+1 // 1*2*3...r
        for i in range(n - r + 1, n + 1):
            res *= i
            res %= p
        for i in range(1, r + 1):
            div *= i
            div %= p
        res *= pow(div, p - 2, p)  # 掛け算に
        res %= p
        return res

    ans = 0
    for k, v in list(dic.items()):
        ans += v * (v - 1) // 2
    print(ans)


if __name__ == "__main__":
    main()

from statistics import median

# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations  # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect

#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
import sys

sys.setrecursionlimit(10000000)
mod = 10**9 + 7


def readInts():
    return list(map(int, input().split()))


def main():
    ana = defaultdict(int)
    n = int(eval(input()))
    for i in range(n):
        s = "".join(sorted(eval(input())))
        ana[s] += 1
    ans = 0
    for k, v in list(ana.items()):
        ans += v * (v - 1) // 2
    print(ans)


if __name__ == "__main__":
    main()

-# from statistics import median +from statistics import median + -# from itertools import combinations # (string,3) 3回 -# from collections import deque -# import collections.defaultdict(list) -# import bisect +from fractions import gcd +from itertools import combinations  # (string,3) 3回 +from collections import deque +from collections import defaultdict +import bisect + +import sys + +sys.setrecursionlimit(10000000) +    ana = defaultdict(int) -    dic = {} -        if s in dic: -            dic[s] += 1 -        else: -            dic[s] = 1 - -    def comb(n, r, p=mod): -        r = min(r, n - r)  # nCr -        res = 1 -        div = 1  # nCr := n*n-1*...n-r+1 // 1*2*3...r -        for i in range(n - r + 1, n + 1): -            res *= i -            res %= p -        for i in range(1, r + 1): -            div *= i -            div %= p -        res *= pow(div, p - 2, p)  # 掛け算に -        res %= p -        return res - +        ana[s] += 1 -    for k, v in list(dic.items()): +    for k, v in list(ana.items()):