while True: try: n=int(input()) for i in range(n): s=input() # 字典放名字中每种字母对应出现的次数 dic={} for j in s: dic[j]=s.count(j) # 每种字母的出现次数从大到小排列 l=sorted(dic.values(),reverse=True) # 次数从大到小依次乘以26,25,24... beauty=0 for x in range(len(l)): beauty+=l[x]*(26-x) print(beauty) except: break