C++ Code :
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll ;
int pos(ll n)
{
if (n == 0)
return 0;
ll msb = 0;
n = n / 2;
while (n != 0) {
n = n / 2;
msb++;
}
return (msb);
}
ll sool(ll x,ll y){
if(x<y){
return x ;
}
else {
ll v2 = pos(x);
ll v5 = pos(y);
//cout<<v2<<" "<<v5 ;
//cout<<"\n";
ll st = max(v2,v5);
ll p_w = (1<<st);
ll k2 = x >> st;
ll p2 = 0 ;
if (k2 & 1) {
p2 = 1 ;
}
else{
p2 = 0 ;
}
ll p5 = 0 ;
ll k5 = y >> st ;
if (k5 & 1) {
p5 = 1 ;
}
else{
p5 = 0 ;
}
//cout<<p2<<" "<<p5 ;
//cout<<"\n";
if(p2==1 && p5==1){
ll z1 = (x^p_w);
if(p_w<y){
ll z2 = p_w + sool((x^p_w),(y^p_w));
return max(z1,z2);
}
else {
return z1 ;
}
}
else if(p2==1 && p5==0){
return sool((x^p_w),y);
}
}
return 0 ;
}
int main() {
ll x,y ;
cin>>x>>y ;
cout<<sool(x,y);
return 0 ;
}