num = [i for i in input().split()]
num1, num2 = int(num[0].replace(num[0][:2], "", 1), 16),int(num[1].replace(num[1][:1], "", 1), 8)  # replace会把所有相同的元素替换掉,限定1次
print(num1+num2)