#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================
vi g[N];
int a[N];
void fac(ll no, vi &a){
a.clear();
while(no){
a.pb(no%2);
no /= 2;
}
while(a.size() < 60) a.pb(0);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int i,n,j;
ll A, B;
cin >> A >> B;
if(A == B){
cout << 1 << endl;
return 0;
}
int r = -1, k = -1, cur = -1;
vi L, R;
fac(A, L);
fac(B, R);
int p = 59;
while(p>=0 and L[p] == R[p]){
if(L[p]) L[p] = R[p] = 0, A -= 1LL<<p, B -= 1LL<<p;
p--;
}
fo(i, 60){
if(L[i] != R[i]) r = i;
if(R[i]) k = cur, cur = i;
}
ll T = 1LL<<r;
//[A, T-1]
ll ans = (T-1) - A + 1;
//[T, T+2^(k+1)-1]
ans += 1LL<<(k+1);
//[T+A, 2T-1]
ans += 2*T-1 - (T+A) + 1;
//If overlap
ll x = (1LL<<(k+1)) - 1;
if(A <= x)
ans -= x-A+1;
cout << ans << endl;
return 0;
}
I2luY2x1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