N=int(eval(input()))

s=[]

cnt=dict()





for _ in range(N):

    tmp=list(eval(input()))

    sotmp=sorted(tmp)

    stmp=''.join(sotmp)

    s.append(stmp)



ss=sorted(s)



for word in ss:

    if((word in list(cnt.keys()))==False):

        cnt[word]=0

    else:

        cnt[word]+=1





total=0

for value in list(cnt.values()):

    total+=(1+value)*value//2



print(total)

def myAnswer(N:int,S:list) -> int:

   counter = 0

   dic = {}

   for s in S:

      if(s in list(dic.keys())):

         dic[s]+=1

      else:

         dic[s] = 0

   for value in list(dic.values()):

      counter += (value * (value + 1)) // 2

   return counter



def modelAnswer():

   return

def main():

   N = int(eval(input()))

   S = ["".join(sorted(list(eval(input())))) for _ in range(N)]

   print((myAnswer(N,S)))

if __name__ == '__main__':

   main()
N = int(eval(input()))
s = []
cnt = dict()
for _ in range(N):
    tmp = list(eval(input()))
    sotmp = sorted(tmp)
    stmp = "".join(sotmp)
    s.append(stmp)
ss = sorted(s)
for word in ss:
    if (word in list(cnt.keys())) == False:
        cnt[word] = 0
    else:
        cnt[word] += 1
total = 0
for value in list(cnt.values()):
    total += (1 + value) * value // 2
print(total)

def myAnswer(N: int, S: list) -> int:
    counter = 0
    dic = {}
    for s in S:
        if s in list(dic.keys()):
            dic[s] += 1
        else:
            dic[s] = 0
    for value in list(dic.values()):
        counter += (value * (value + 1)) // 2
    return counter


def modelAnswer():
    return


def main():
    N = int(eval(input()))
    S = ["".join(sorted(list(eval(input())))) for _ in range(N)]
    print((myAnswer(N, S)))


if __name__ == "__main__":
    main()

-N = int(eval(input())) -s = [] -cnt = dict() -for _ in range(N): -    tmp = list(eval(input())) -    sotmp = sorted(tmp) -    stmp = "".join(sotmp) -    s.append(stmp) -ss = sorted(s) -for word in ss: -    if (word in list(cnt.keys())) == False: -        cnt[word] = 0 -    else: -        cnt[word] += 1 -total = 0 -for value in list(cnt.values()): -    total += (1 + value) * value // 2 -print(total) +def myAnswer(N: int, S: list) -> int: +    counter = 0 +    dic = {} +    for s in S: +        if s in list(dic.keys()): +            dic[s] += 1 +        else: +            dic[s] = 0 +    for value in list(dic.values()): +        counter += (value * (value + 1)) // 2 +    return counter + + +def modelAnswer(): +    return + + +def main(): +    N = int(eval(input())) +    S = ["".join(sorted(list(eval(input())))) for _ in range(N)] +    print((myAnswer(N, S))) + + +if __name__ == "__main__": +    main()