import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // Life is short, i love JAVA.
        // System.out.println(Integer.valueOf(in.next().substring(2), 16));
        String str = in.nextLine();
        int result = 0, i = 2, len = str.length();
        while (i < len) {
            char c = str.charAt(i++);
            int ch;
            if (c >= '0' && c <= '9') {
                ch = c - '0';
            } else if (c >= 'a' && c <= 'z') {
                ch = c - 'a' + 10;
            } else {
                ch = c - 'A' + 10;
            }
            result *= 16;
            result += ch;
        }
        System.out.println(result);
    }
}