while True: try: n = int(input()) for i in range(n): s = input().strip() d = {} for i in s: if i in d.keys(): d[i]+=1 else: d[i]=1 l = sorted(d.values(),reverse=True) # print(l) Sum = 0 a = 26 for i in l: Sum += a*i a -= 1 print(Sum) except: break
while True: try: n = int(input()) for i in range(n): s = input().strip() d = {} for i in s: if i in d.keys(): d[i]+=1 else: d[i]=1 l = sorted(d.values(),reverse=True) # print(l) Sum = 0 a = 26 for i in l: Sum += a*i a -= 1 print(Sum) except: break