N=int(eval(input()))

s=[0]*N

essence={}

count=0

for i in range(N):

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

   s[i]=s_i

   if s[i] not in essence:

      essence.setdefault(s[i],1)

   else:

      count+=essence[s[i]]

      essence[s[i]]+=1



print(count)
from sys import stdin

def nC2(n):

    return n*(n-1)//2



def main():

    #入力

    readline=stdin.readline

    N=int(readline())

    s=[""]*N

    for i in range(N):

        a=list(readline().strip())

        a.sort()

        s[i]="".join(a)



    d=dict()

    for i in range(N):

        if s[i] not in d:

            d[s[i]]=1

        else:

            d[s[i]]+=1



    res=0

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

        if v==1:

            pass

        else:

            res+=nC2(v)



    print(res)

    

if __name__=="__main__":

    main()
N = int(eval(input()))
s = [0] * N
essence = {}
count = 0
for i in range(N):
    s_i = "".join(sorted(eval(input())))
    s[i] = s_i
    if s[i] not in essence:
        essence.setdefault(s[i], 1)
    else:
        count += essence[s[i]]
        essence[s[i]] += 1
print(count)

from sys import stdin


def nC2(n):
    return n * (n - 1) // 2


def main():
    # 入力
    readline = stdin.readline
    N = int(readline())
    s = [""] * N
    for i in range(N):
        a = list(readline().strip())
        a.sort()
        s[i] = "".join(a)
    d = dict()
    for i in range(N):
        if s[i] not in d:
            d[s[i]] = 1
        else:
            d[s[i]] += 1
    res = 0
    for v in list(d.values()):
        if v == 1:
            pass
        else:
            res += nC2(v)
    print(res)


if __name__ == "__main__":
    main()

-N = int(eval(input())) -s = [0] * N -essence = {} -count = 0 -for i in range(N): -    s_i = "".join(sorted(eval(input()))) -    s[i] = s_i -    if s[i] not in essence: -        essence.setdefault(s[i], 1) -    else: -        count += essence[s[i]] -        essence[s[i]] += 1 -print(count) +from sys import stdin + + +def nC2(n): +    return n * (n - 1) // 2 + + +def main(): +    # 入力 +    readline = stdin.readline +    N = int(readline()) +    s = [""] * N +    for i in range(N): +        a = list(readline().strip()) +        a.sort() +        s[i] = "".join(a) +    d = dict() +    for i in range(N): +        if s[i] not in d: +            d[s[i]] = 1 +        else: +            d[s[i]] += 1 +    res = 0 +    for v in list(d.values()): +        if v == 1: +            pass +        else: +            res += nC2(v) +    print(res) + + +if __name__ == "__main__": +    main()