#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int get_bit(const LL num, const int i)
{ return (num >> i) & 1; }    /* Returns the i-th bit value of num. */

/*
 * Given a range of integers [A,B], count how many values can be
 * obtained by ORing a non-empty subset of [A,B].
 */
/*
 * 这题需要找出一个分界点, 即找到最高位的B是1, A是0的位置x, 那么对于所有
 * OR 的结果, x处要么是1要么是0.
 *                 |
 * => A |1|0|0|1|0|0|1|0|1|1|0|1|
 * => B |1|0|0|1|0|1|0|0|1|0|1|0|
 *      |x|x|x|x|x|
 *
 * x是0有多少种呢? 这里就需要从[A,1<<x)里 挑选数进行OR, 即有(1<<x)-A种,
 * 因为A到(1<<x)-1都可以表示出来;
 *
 * x处为1有几种呢? 有两种情况:
 *
 * ①从(1<<x, B]里挑选, 结果就不说了依此类推,
 *
 * ②从上述两个区间都挑选, 那就是也是(1<<x)-A种, 然后上述两种两种情况
 * 可能会有重复, 需要判断去重, 最后判读是否要加上(1<<x)这一种就行了.
 */
/*
 * If A = B, the answer is obviously 1. We assume that A < B.
 *
 * Let r be the largest integer such that the r-th (0-based) bit of A
 * and the r-th bit of B are different. By the definition of r, the
 * (r+1)-th bit or higher bits are the SAME FOR ALL integers between
 * A and B. Thus, we CAN IGNORE them, and we can assume that
 * 0 <= A < 2^r and 2^r <= B < 2^(r+1).
 *
 * Let T = 2^r, X = {A,A+1, .. T−1}, and Y = {T,T+1, .. B}.
 *
 * If we use only integers from the set X, we can construct integers
 * between A and T−1 (pick every one element). We can only construct
 * these numbers (The minimum possible OR is A, and the OR of all
 * elements is T−1).
 *
 * If we use only integers from the set Y, we can construct all integers
 * between T and the OR of all integers in Y. Let k be the largest
 * integer such that 2^r + 2^k is in the set Y. Since all of
 * 2^r, 2^r+2^0, .. 2^r+2^k are in the set Y, we can construct all
 * integers between 2^r and 2^r + 2^(k+1) - 1. It's easy to see that the
 * OR of all elements in Y is 2^r + 2^(k+1) - 1.
 *
 * If we use both integers from X and integers from Y, we can construct
 * integers between T+A and 2T−1, inclusive (choose T and one element
 * from X). We can only construct these numbers (The minimum possible OR
 * is T+A, and the OR of all elements is 2T−1).
 *
 * The set of possible integers is the union of the three intervals
 * above. Note that the second and the third intervals may overlap.
 */

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    LL A,B;
    while (cin >> A >> B) {
        LL ans = 0;
        if (A == B)
            ans = 1;
        else {
            int i,j;
            for (i = 61; i >= 0; --i) {
                if ((B & 1LL<<i) && ((A & 1LL<<i) == 0))
                    break;
                if (A & 1LL<<i)
                    A ^= 1LL<<i;
                if (B & 1LL<<i)
                    B ^= 1LL<<i;
            }
            ans += (1LL<<i) - A;
            /*
             * |1|0|0|1|x|x|
             *       |1|1|1| every bit can be constructed
             */
            for (j = i-1; j >= 0; --j) {
                if (B & 1LL<<j) {
                    ans += (1LL<<(j+1)) - 1;
                    break;
                }
            }
            ans += (1LL<<i) - A;
            if (j != -1 && A <= (1LL<<(j+1))-1)
                ans -= (1LL<<(j+1)) - A;
            ans += (i != 0);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256