#include<bits/stdc++.h> #define LL long long usingnamespace std; LL x, y, z, k, maxn; int T, id, i; LL ans; intmain() { scanf("%lld%lld", &x, &y); if(x == y) { puts("1"); return0; } z = x ^ y; while(z) { id ++; z >>= 1; } id --; z = (y >> id) << id; k = z ^ y; ans = z - x; while(k) { i ++; k >>= 1; } i --; maxn = y | ((1ll << (i + 1)) - 1); LL l = x | z, r = z | (z - 1); if(maxn < l) ans += maxn - z + 1 + r - l + 1; else ans += r - z + 1; cout << ans << endl; return0; }