// Arup Guha
// 1/18/2014
// Solution to 2006 MCPC Problem A: Quick Sum

import java.util.*;

public class a {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		String s = stdin.nextLine();

		// Go through each score.
		while (!s.equals("#")) {

			// Skip spaces and multiply the 1-based rank number by the letter's value.
			int score = 0;
			for (int i=0; i<s.length(); i++) {
				char c = s.charAt(i);
				if (c != ' ')score += (i+1)*(c - 'A' + 1);
			}
			
			// Output result and go to next case.
			System.out.println(score);
			s = stdin.nextLine();
		}
	}
}