#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;


//121
ll XOR0toX(ll X) {
	ll result = ((X + 1) / 2) % 2;

	ll bit = 1;
	ll frec = 4;
	while (frec <= 9000000000000)
	{
		ll bit_val = 0;

		if (X < frec / 2) {
			bit_val = 0;
		}
		else if((X % frec) < frec / 2) {
			bit_val = 0;
		}
		else {
			bit_val = X % 2 == 0 ? 1 : 0;
		}

		result |= (bit_val << bit);

		frec *= 2;
		bit++;
	}

	return result;
}

int main() {
	ll A, B;
	scanf("%lld %lld", &A, &B);

	ll result = XOR0toX(B);

	if (A > 0) {
		result ^= XOR0toX(A - 1);
	}

	printf("%lld\n", result);

	return 0;
}

//122
/*
int main() {
	ll N;
	scanf("%lld", &N);

	static ll dp[110][130];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;

	for (ll j = 0; j < N; j++) {
		for (ll i = 0; i < 125; i++) {
			if (dp[j][i] == 0) {
				continue;
			}

			for (int c = 1; c < 5; c++) { //���̕������
				//*AG
				if (i == 0 * 25 + 1 * 5 + 3 || 
					i == 1 * 25 + 1 * 5 + 3 ||
					i == 2 * 25 + 1 * 5 + 3 ||
					i == 3 * 25 + 1 * 5 + 3 ||
					i == 4 * 25 + 1 * 5 + 3) {
					//*AG+C
					if (c == 2) {
						continue;
					}
				}

				//*AC
				if (i == 0 * 25 + 1 * 5 + 2 ||
					i == 1 * 25 + 1 * 5 + 2 ||
					i == 2 * 25 + 1 * 5 + 2 ||
					i == 3 * 25 + 1 * 5 + 2 ||
					i == 4 * 25 + 1 * 5 + 2) {
					//*AC+G
					if (c == 3) {
						continue;
					}
				}

				//*GA
				if (i == 0 * 25 + 3 * 5 + 1 ||
					i == 1 * 25 + 3 * 5 + 1 ||
					i == 2 * 25 + 3 * 5 + 1 ||
					i == 3 * 25 + 3 * 5 + 1 ||
					i == 4 * 25 + 3 * 5 + 1) {
					//*GA+C
					if (c == 2) {
						continue;
					}
				}

				//A*G
				if (i == 1 * 25 + 0 * 5 + 3 ||
					i == 1 * 25 + 1 * 5 + 3 ||
					i == 1 * 25 + 2 * 5 + 3 ||
					i == 1 * 25 + 3 * 5 + 3 ||
					i == 1 * 25 + 4 * 5 + 3) {
					//A*G+C
					if (c == 2) {
						continue;
					}
				}

				//AG*
				if (i == 1 * 25 + 3 * 5 + 0 ||
					i == 1 * 25 + 3 * 5 + 1 ||
					i == 1 * 25 + 3 * 5 + 2 ||
					i == 1 * 25 + 3 * 5 + 3 ||
					i == 1 * 25 + 3 * 5 + 4) {
					//AG*+C
					if (c == 2) {
						continue;
					}
				}

				//���̕�������
				ll nextStr = ((i * 5) % 125) + c;

				//�z��DP
				dp[j + 1][nextStr] += dp[j][i];
				dp[j + 1][nextStr] %= MOD;
			}
		}
	}

	ll result = 0;
	for (ll i = 0; i < 125; i++) {
		result += dp[N][i];
		result %= MOD;
	}
	printf("%lld\n", result);
}
*/


//123
/*
struct ValueCombi{
	ll sumValue = 0;
	ll indexX = 0;
	ll indexY = 0;
	ll indexZ = 0;
	ll combiIndex() {
		return indexX * 1000000 + indexY * 1000 + indexZ;
	}
};

// "<" �̃I�[�o�[���[�h num����ɑ召��r���s��
bool operator< (const ValueCombi &a, const ValueCombi &b) {
	return a.sumValue < b.sumValue;
};

int main() {
	ll X, Y, Z, K;
	scanf("%lld %lld %lld %lld", &X, &Y, &Z, &K);

	vector<ll> valX(X);
	for (ll i = 0; i < X; i++) {
		scanf("%lld", &valX[i]);
	}

	vector<ll> valY(Y);
	for (ll i = 0; i < Y; i++) {
		scanf("%lld", &valY[i]);
	}

	vector<ll> valZ(Z);
	for (ll i = 0; i < Z; i++) {
		scanf("%lld", &valZ[i]);
	}

	std::sort(valX.begin(), valX.end(), std::greater<ll>());
	std::sort(valY.begin(), valY.end(), std::greater<ll>());
	std::sort(valZ.begin(), valZ.end(), std::greater<ll>());

	map<ll, int> inQ; //X*1000000+Y*1000+Z
	priority_queue<ValueCombi> pQ;

	//�܂�0,0,0������
	ValueCombi c;
	c.indexX = 0;
	c.indexY = 0;
	c.indexZ = 0;
	c.sumValue = valX[0] + valY[0] + valZ[0];
	pQ.push(c);
	inQ[c.combiIndex()] = 1;

	int output_count = 0;

	while (pQ.empty() == false) {
		//�ő�l�ƂȂ�g�ݍ��킹�����o��
		c = pQ.top();
		pQ.pop();

		inQ[c.combiIndex()] = 2;
		printf("%lld\n", c.sumValue);
		output_count++;
		if (output_count >= K) {
			break;
		}

		ValueCombi next;
		ValueCombi temp;

		//X�̎�
		if (c.indexX <= X - 2) {
			next = c;
			next.indexX++;
			
			temp = next;
			temp.indexY--;
			if (temp.indexY < 0 || inQ[temp.combiIndex()] == 2) {
				temp = next;
				temp.indexZ--;
				if (temp.indexZ < 0 || inQ[temp.combiIndex()] == 2) {
					next.sumValue = valX[next.indexX] + valY[next.indexY] + valZ[next.indexZ];
					pQ.push(next);
					inQ[next.combiIndex()] = 1;
				}
			}
		}

		//Y�̎�
		if (c.indexY <= Y - 2) {
			next = c;
			next.indexY++;

			temp = next;
			temp.indexX--;
			if (temp.indexX < 0 || inQ[temp.combiIndex()] == 2) {
				temp = next;
				temp.indexZ--;
				if (temp.indexZ < 0 || inQ[temp.combiIndex()] == 2) {
					next.sumValue = valX[next.indexX] + valY[next.indexY] + valZ[next.indexZ];
					pQ.push(next);
					inQ[next.combiIndex()] = 1;
				}
			}
		}

		//Z�̎�
		if (c.indexZ <= Z - 2) {
			next = c;
			next.indexZ++;

			temp = next;
			temp.indexX--;
			if (temp.indexX < 0 || inQ[temp.combiIndex()] == 2) {
				temp = next;
				temp.indexY--;
				if (temp.indexY < 0 || inQ[temp.combiIndex()] == 2) {
					next.sumValue = valX[next.indexX] + valY[next.indexY] + valZ[next.indexZ];
					pQ.push(next);
					inQ[next.combiIndex()] = 1;
				}
			}
		}

	}
}
*/


//125
/*
int main() {
	ll N;
	scanf("%lld", &N);

	ll abs_min = 100000000000;
	ll sum = 0;
	ll count_negative = 0;
	ll count_zero = 0;
	for (ll i = 0; i < N; i++) {
		ll num;
		scanf("%lld", &num);
		abs_min = std::min(std::abs(num), abs_min);

		if (num < 0) {
			count_negative++;
		}
		else if (num == 0) {
			count_zero++;
		}

		sum += std::abs(num);
	}

	ll result = 0;
	if (count_zero > 0) {
		result = sum;
	}
	else if (count_negative % 2 == 0) {
		result = sum;
	}
	else {
		result = sum - abs_min * 2;
	}

	printf("%lld\n", result);

	return 0;
}
*/

//124
/*
int main() {
	ll N, K;
	scanf("%lld %lld", &N, &K);

	char s[100010];
	scanf("%s", &s);

	vector<ll> state_length; //index0,2,4,...�͋t����

	int prev_state = 1; //�ŏ��������Ƃ�����index0��0������悤��
	ll length = 0;
	for (ll i = 0; i < N; i++) {
		char c = s[i];
		if (c == '0') {
			//��
			if (prev_state == 0) {
				length++;
			}
			else {
				state_length.push_back(length);
				length = 1;
				prev_state = 0;
			}
		}
		else {
			//�t
			if (prev_state == 1) {
				length++;
			}
			else {
				state_length.push_back(length);
				length = 1;
				prev_state = 1;
			}
		}
	}
	state_length.push_back(length);
	if (prev_state == 1) {
		state_length.push_back(0); //�Ō�͐��ŏI���悤��
	}
	else {
		state_length.push_back(0);
		state_length.push_back(0); //�Ō�͐��ŏI���悤��
	}

	ll state_length_size = (ll)state_length.size();
	ll window = std::min(state_length_size, 1 + K * 2);
	ll start = 0;
	ll end = window;
	ll sum = 0;
	for (int i = start; i < end; i++) {
		sum += state_length[i];
	}
	ll max = sum;

	while (true) {
		start += 2;
		end += 2;
		if (end >= state_length_size) {
			break;
		}

		sum -= state_length[start - 2];
		sum -= state_length[start - 1];
		sum += state_length[end - 2];
		sum += state_length[end - 1];

		if (sum > max) {
			max = sum;
		}
	}

	printf("%lld\n", max);

	return 0;
}
*/


Measured memory_bytes: 256