#include <iostream>
using namespace std;
int main(){
unsigned long long a,b;
while(cin >> a >> b) {
unsigned long long ans=0;
for(short i=63; i>=0; i--) {
if((a & (1 << i))==(b&(1<<i)))
ans+=(a&(1<<i));
else
break;
}
cout << ans << endl;
}
return 0;
}