import string n = int(input()) while True: try: s = input().lower() lows = string.ascii_lowercase result = [] out = 0 for i in lows: c = s.count(i) if c > 0: result.append(c)
newresult = (sorted(result))[::-1]
for i in range(len(newresult)):
a = (26-i) * newresult[i]
out += a
print(out)
except:
break