#include <bits/stdc++.h>

using namespace std;

int main() {

	long long a, b;
	cin >> a >> b;
	int pos;
	if(a == b) {
		puts("1");	
	} else {
		for (int i = 60; i >= 0; --i) {
			if((a &(1LL<<i)) == (b &(1LL<<i))) {
				a -= (a &(1LL<<i));
				b -= (b &(1LL<<i));
			} else {
				pos = i;
				break;
			}
		}
		long long p2 = 1LL << pos;

		long long zero = p2 - a; // a ... p2-1

		long long bn = b - p2;
		int pos_bn;
		if(bn == 0) {
			pos_bn = -1;
		} else{
			pos_bn = 63 - __builtin_clzll(bn);
		}

		long long b_lower = 1LL<<(pos_bn+1); // 0 .. (1LL<<(pos_bn+1)-1)
		long long b_upper = zero; // a ... p2-1

		long long sum = b_lower + b_upper;
		if(b_lower + b_upper >= p2) {
			sum = p2;
		}
		printf("%lld\n", zero+sum);
	}



}