while True: try: n = int(input()) for i in range(n): L = [] name = input() for j in set(list(name)): L.append(name.count(j)) L.sort(reverse=True) res = 0 for k in range(len(L)): res += L[k]*(26-k) print(res) except: break
while True: try: n = int(input()) for i in range(n): L = [] name = input() for j in set(list(name)): L.append(name.count(j)) L.sort(reverse=True) res = 0 for k in range(len(L)): res += L[k]*(26-k) print(res) except: break