import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String hexadecimal = str.replace("0x", "").toUpperCase();
        int length = hexadecimal.length();
        HashMap<Character, Integer> map = new HashMap<>();
        map.put('A', 10);
        map.put('B', 11);
        map.put('C', 12);
        map.put('D', 13);
        map.put('E', 14);
        map.put('F', 15);
        int sum = 0;
        int pos = 0;
        for (int i = length - 1; i >= 0; i--) {
            char key = hexadecimal.charAt(i);
            int value;
            if (key > '9') {
                value = map.get(key);
            } else {
                value = key - '0';
            }
            sum += Math.pow(16, pos) * value;
            pos++;
        }
        System.out.println(sum);
    }
}