'''

                            Online Python Compiler.
                Code, Compile, Run and Debug python program online.
Write your code in this editor and press "Run" button to execute it.

'''
a=int(input());
b=int(input());
while(a!=0 and b!=0):
    c=a^b
    b=a&b
    b<<=1
    a=c


print(a);