import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str1 = sc.next();
String str2 = sc.next();
int a = Integer.parseInt(str1.replaceAll("^0[x|X]",""),16);
int b = Integer.parseInt(str2.replaceAll("^0",""),8);
long sum = (long)a + (long)b;
System.out.println(sum);
}
}