#include<stdio.h>
#include<string.h>
int main() {
char s[256];
while(gets(s)){
if(s[0] == '#') break;
int sum = 0;
for(int i=0;i<strlen(s);i++){
if(s[i] >= 'A' && s[i] <= 'Z' ){
sum = sum + (s[i]- 'A' + 1) * (i+1);
}
}
printf("%d\n",sum);
}
return 0;
}