import java.util.*;
import java.util.stream.Stream;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
// while (in.hasNextInt()) { // 注意 while 处理多个 case
// int a = in.nextInt();
// int b = in.nextInt();
// System.out.println(a + b);
// }
String n = in.nextLine();
while (in.hasNextLine()) {
String s = in.nextLine();
char[] cs = s.toCharArray();
List<Node> nodes = new ArrayList<>();
nodes.add(new Node(s.charAt(0), 1));
for (int i = 1; i < s.length(); i++) {
boolean has = false;
for (int j = 0; j < nodes.size(); j++) {
if (s.charAt(i) == nodes.get(j).c) {
nodes.get(j).count++;
has = true;
}
}
if (!has) {
char c = s.charAt(i);
Node node = new Node(c, 1);
nodes.add(node);
}
}
Collections.sort(nodes);
int sum = 0;
int j = 26;
for (int i = 0; i < nodes.size(); i++) {
sum += j * nodes.get(i).count;
j--;
}
System.out.println(sum);
}
}
}
class Node implements Comparable {
char c;
int count;
Node (char c, int count) {
this.c = c;
this.count = count;
}
@Override
public int compareTo(Object o) {
Node node = (Node)o;
return node.count - this.count;
}
}