// #define _GLIBCXX_DEBUG
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define rep0(N) for (int COUNTER = 0; COUNTER < (int)(N); COUNTER++)
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
#define rep1(i, N) for (int i = 0; i < (int)(N); i++)
#define rep2(i, START, GOAL) for (int i = (int)(START); i < (int)(GOAL); i++)
#define rep3(i, START, GOAL) for (int i = (int)(START); i > (int)(GOAL); i--)
template <typename T> bool chmax(T &a, const T &b) { if (a < b) {	a = b; return true;	}	return false; }
template <typename T> bool chmin(T &a, const T &b) { if (a > b) {	a = b; return true;	}	return false; }
#define all(CONTAINER) CONTAINER.begin(), CONTAINER.end()
#define rall(CONTAINER) CONTAINER.rbegin(), CONTAINER.rend()
#define from1(CONTAINER) CONTAINER.begin() + 1, CONTAINER.end()
#define rfrom1(CONTAINER) CONTAINER.rbegin(), CONTAINER.rend() - 1
// #define sum(X) accumulate(all(X), 0);
template <typename T> T sum(vector<T> &VEC) { return accumulate(all(VEC), 0.0); }
#define maxel(X) *max_element(all(X))
#define minel(X) *min_element(all(X))
#define pout(X) cout << X << " "
#define print(X) cout << X << "\n"
#define output(X) cout << X << "\n"
#define putout(X) cout << X << "\n"
#define dbe(X) cerr << X << " "
#define dbel(X) cerr << X << "\n"
#define dberr(X) cerr << X << " "
#define dberrl(X) cerr << X << "\n"
#define db(X) cerr << #X << ":" << (X) << " "
#define dbl(X) cerr << #X << ":" << (X) << "\n"
#define db2(X, Y) cerr << #X << ":" << (X) << ", " << #Y << ":" << (Y) << " "
#define db2l(X, Y) cerr << #X << ":" << (X) << ", " << #Y << ":" << (Y) << "\n"
#define dbl2(X, Y) cerr << #X << ":" << (X) << "\n" << #Y << ":" << (Y) << "\n"
#define db3(X, Y, Z) cerr << #X << ":" << (X) << ", " << #Y << ":" << (Y) << " " << #Z << ":" << (Z) << " "
#define db3l(X, Y, Z) cerr << #X << ":" << (X) << ", " << #Y << ":" << (Y) << ", " << #Z << ":" << (Z) << "\n"
#define dbl3(X, Y, Z) cerr << #X << ":" << (X) << "\n" << #Y << ":" << (Y) << "\n" << #Z << ":" << (Z) << "\n"
#define db4(X, Y, Z, W) cerr << #X << ":" << (X) << ", " << #Y << ":" << (Y) << " " << #Z << ":" << (Z) << ", " << #W << ":" << (W) << " "
#define db4l(X, Y, Z, W) cerr << #X << ":" << (X) << ", " << #Y << ":" << (Y) << " " << #Z << ":" << (Z) << ", " << #W << ":" << (W) << "\n"
#define dbl4(X, Y, Z, W) cerr << #X << ":" << (X) << "\n" << #Y << ":" << (Y) << "\n" << #Z << ":" << (Z) << "\n" << #W << ":" << (W) << "\n"
#define dbp(PAIR) cerr << #PAIR << ":(" << PAIR.first << ", " << PAIR.second << ") "
#define dbpl(PAIR) cerr << #PAIR << ":(" << PAIR.first << ", " << PAIR.second << ")\n"
#define dbt3(TUPLE3) cerr << #TUPLE3 << ":(" << get<0>(TUPLE3) << ", " << get<1>(TUPLE3) << ", " << get<2>(TUPLE3) << ") "
#define dbt3l(TUPLE3) cerr << #TUPLE3 << ":(" << get<0>(TUPLE3) << ", " << get<1>(TUPLE3) << ", " << get<2>(TUPLE3) << ")\n"
#define dbt4(TUPLE4) cerr << #TUPLE4 << ":(" << get<0>(TUPLE4) << ", " << get<1>(TUPLE4) << ", " << get<2>(TUPLE4) << ", " << get<3>(TUPLE4) << ") "
#define dbt4l(TUPLE4) cerr << #TUPLE4 << ":(" << get<0>(TUPLE4) << ", " << get<1>(TUPLE4) << ", " << get<2>(TUPLE4) << ", " << get<3>(TUPLE4) << ")\n"
#define dbv(VEC) cerr << #VEC << ":{ "; for (auto ELEM : VEC) cerr << ELEM << ", "; cerr << "}\n"
#define dbvp(VP) cerr << #VP << ":{ "; for (auto PAIR : VP) cerr << "(" << PAIR.first << ", " << PAIR.second << "), "; cerr << "}\n"
#define dbvv(VV) cerr << #VV << ":{\n"; for (auto VEC : VV) { cerr << "{ "; for (auto ELEM : VEC) cerr << ELEM << ", "; cerr << "},\n"; } cerr << "}\n"
// dbvve
#define dbvvp(VVP) cerr << #VVP <<":{\n"; for (auto VP : VVP) { cerr << "{ "; for (auto PAIR : VP) { cerr << "(" << PAIR.first << ", " << PAIR.second << "), "; } cerr << "},\n"; } cerr << "}\n";
#define dbs(SET) cerr << #SET << "{ "; for (auto ELEM : SET) cerr << ELEM << ", "; cerr << "}\n";
#define dbsp(SP) cerr << #SP << "{ "; for (auto PAIR : SP) cerr << "(" << PAIR.first << ", " << PAIR.second << "), "; "}\n";
#define dbm(MAP) cerr << #MAP << ":{ "; for (auto PAIR : MAP) cerr << "(" << PAIR.first << ", " << PAIR.second << "), "; cerr << "}\n"
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using pii = pair<int, int>;using pll = pair<ll, ll>;using pdd = pair<double, double>;
using ti3 = tuple<int, int, int>;using tl3 = tuple<ll, ll, ll>;using td3 = tuple<double, double, double>;
using ti4 = tuple<int, int, int, int>;using tl4 = tuple<ll, ll, ll, ll>;using td4 = tuple<double, double, double, double>;
using vi = vector<int>;using vl = vector<ll>;using vd = vector<double>;using vs = vector<string>;using vb = vector<bool>;
using vvi = vector<vi>;using vvl = vector<vl>;using vvd = vector<vd>;using vvs = vector<vs>;using vvb = vector<vb>;
using v3i = vector<vvi>;using v3l = vector<vvl>;using v3d = vector<vvd>;using v3s = vector<vvs>;using v3b = vector<vvb>;
using vpii = vector<pii>;using vpll = vector<pll>;using vpdd = vector<pdd>;
using mii = map<int, int>;using mll = map<ll, ll>;
using si = set<int>;using sl = set<ll>;using ss = set<string>;
using spii = set<pii>;using spll = set<pll>;using spdd = set<pdd>;
// db

bool countbit(ll N, int k) { // [0,N]でのカウント
	assert(N >= 0);
	// db(N); dbl(bitset<40>(N));
	if (k == 0) return (N + 1) & (1 << 1);
	ll r = N & ((1LL << (k + 1)) - 1);
	if (r < (1LL << k)) return false;
	else return !(r & 1);
}

bool solve(ll A, ll B, int k) { // [A,B]でのカウント
	assert(A <= B);
	if (A == 0) return countbit(B, k);
	else return countbit(A - 1, k) ^ countbit(B, k);
}

int main() {
	ll A, B; cin >> A >> B;	
	// (下から)0桁目，2^0の位bitをまず考える。
	// [A,B+1)にx&1==1となるxがいくつあるか→[0,B+1)での個数マイナス[0,A)での個数
	// [0,N+1)でのx&1==1なるxは，奇数の個数なので，[(N+1)/2]個。 mod2で見ると，各[2m,2m+1]に1つある。(0,1)
	// ※[2m,2m+1]に1つ(奇数)しかないので，このk=0のときだけ例外になる。
	//
	// [0,N+1)にx&10==1なるxはいくつあるか?
	// mod4で見ると，各(4m,4m+1,4m+2,4m+3)に2つある。
	// よって，N%4が0,1,2,3なら，偶数，偶数，奇数，偶数(個)ある。(00,01,10,11)
	//
	// [0,N+1)にx&100==1なるxはいくつあるか?
	// mod8で見ると，各[8m,8m+7]に4つある。
	// よって，N%8が0~7なら，偶数，偶数，偶数，偶数，奇数，偶数，奇数，偶数(個)ある。(000,001,010,011,100,101,110,111)
	// 
	// →[0,N+1)に x & (1<<k) == 1 なるxがいくつあるか? (k>0)
	// Nを2^(k+1)で割った余りが2^k未満なら偶数個，そうでなければ余りの偶奇を反転させた個数ある　※k=0のときは例外
	//
	// 2^40 > 10^12 である。
	bitset<40> ansbit(0);
	rep(k, 40) {
		// dbl(k);
		// db3l(countbit(B,k), countbit(A-1,k), solve(A,B,k));
		if (solve(A, B, k)) ansbit.set(k);
		// dbl(ansbit);
	}
	print(ansbit.to_ullong());	
}

Measured memory_bytes: 256