import java.util.Scanner;

/**
 * HJ5 进制转换
 */
public class HJ005 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextLine()) {
            String s = sc.nextLine();
            String s1 = s.substring(2);
            int a = Integer.parseInt(s1, 16);
            System.out.println(a);
        }
        sc.close();
    }

}