package com.array1;

import java.util.*;

public class Bijiao {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
Integer z = Integer.parseInt(sc.nextLine());
for (int a = 0; a < z; a++) {
String str = sc.nextLine();
String[] array = str.split("");
Map<String,Integer> map = new HashMap<String,Integer>();
for (int i = 0; i < array.length; i++) {
String s = array[i];
if(map.get(s)!=null){
map.put(s,map.get(s)+1);
}else {
map.put(s,1);
}
}
ArrayList<Map.Entry<String,Integer>> list = new ArrayList<Map.Entry<String,Integer>>(map.entrySet());
Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() {
@Override
public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
return o2.getValue().compareTo(o1.getValue());
}
}
);
int m = 26;
int sum=0;
for(Map.Entry<String,Integer> en :list){
sum = sum+en.getValue()*m;
m--;
}
System.out.println(sum);
}

}

}