import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String aHex = in.next();
        String bOct = in.next();
        int a = Integer.parseInt(aHex.substring(2,aHex.length()), 16);//去掉16进制的前两位0x标志位,之后转化为十进制
        int b = Integer.parseInt(bOct.substring(1,bOct.length()), 8);//去掉8进制的前两位0标志位,之后转化为十进制
        System.out.println(a + b);
    }
}