public class Main{
    public static void main(String[]args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        
        String[] st = str.split(" ");
        System.out.println(Integer.valueOf(st[0].substring(2) ,16)+Integer.valueOf(st[1].substring(1) ,8));
    }
}