import java.util.Scanner;

public class ExcelColumnToNumber {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String column = sc.nextLine().trim();

        // Check for lowercase or invalid input
        if (!column.matches("[A-Z]+")) {
            System.out.println("Invalid input");
            return;
        }

        long result = 0; // use long (safe for length ≤ 7)
        for (int i = 0; i < column.length(); i++) {
            char ch = column.charAt(i);
            result = result * 26 + (ch - 'A' + 1);
        }

        System.out.println(result);
    }
}