/*
B - The Sparsest Number in Between
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > pbds;
// find_by_order, order_by_key
#define sp << " " <<
#define ll unsigned long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define PI 3.1415926535897932384626
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sortall(x) sort(all(x))
#define sortrall(x) sort(rall(x))
#define printv(v) for(auto x : v) cout << x << " "; cout << "\n"
#define printm(m) for(auto x : m) cout << x.F sp x.S << "\n"
#define make_unique(x) sortall(x); (x).resize(unique(all(x)) - (x).begin())
#define numtobin(n) bitset<64>(n).to_string()
#define bintoint(bin_str) stoi(bin_str, nullptr, 2)
#define bintoll(bin_str) stoll(bin_str, nullptr, 2)
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
template<typename T1, typename T2>
using safe_map = unordered_map<T1, T2, custom_hash>;
template<typename T>
using safe_set = unordered_set<T, custom_hash>;
template<typename T>
void debug(T x) { cerr << x << endl; }
template<typename T, typename... Args>
void debug(T x, Args... args) { cerr << x << " "; debug(args...); }
void fastIO() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
void fraction() {
cout.unsetf(ios::floatfield);
cout.precision(10);
cout.setf(ios::fixed,ios::floatfield);
}
void yn(bool res, bool cap = true) {
vector<string> s = {"Yes", "YES", "No", "NO"};
cout << ((res) ? s[0 + cap] : s[2 + cap]) << "\n";
}
void chmin(ll &x, ll y) { x = min(x, y); }
void chmax(ll &x, ll y) { x = max(x, y); }
inline ll nxt() { ll x; cin >> x; return x;}
inline ld nxtD() { ld x; cin >> x; return x;}
inline string nxtStr() { string x; cin >> x; return x;}
const int mod = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
void proc(){
}
// stress testing
int sol(int x, int y) {
int ans = x;
int cnt = __builtin_popcount(x);
while(y >= x) {
int r = __builtin_popcount(x);
if(cnt > r) {
cnt = r;
ans = x;
}
x++;
}
return ans;
}
void solve(int xl = 1, int xr = 1) {
ll a, b; cin >> a >> b;
// ll a = xl, b = xr;
ll ans = a;
bool p = false;
auto countBit = [&](ll x) ->int {
int res = 0;
while(x){
if(x & 1) res++;
x >>= 1;
}
return res;
};
for(int i = 0; i < 64; i++) {
ll p = (1ll << i);
if(a <= p && p <= b) {
cout << p << "\n";
return;
}
}
int l = countBit(a);
for(int i = 64; i >= 0; i--) {
if ((a >> i) & 1) p = true;
if(!((a >> i) & 1) && ((b >> i) & 1) && p) {
ll tmp = a;
int l = i;
while(i--) {
if((tmp >> i) & 1)
tmp ^= (1ll << i);
}
for(int j = 0; j <= l; j++) {
if((tmp | (1ll << j)) >= a) {
tmp |= (1ll << j);
a = tmp;
break;
}
}
break;
}
}
int r = countBit(a);
if(r == l) ans = min(a, ans);
else if(l > r) ans = a;
cout << ans << "\n";
// ll chk = sol(xl, xr);
// yn(chk == ans);
// debug(xl, xr, ans, sol(xl, xr));
}
int main() {
fastIO();
proc();
int tc = 1;
// tc = nxt();
for (int t = 1; t <= tc; t++) {
// cout << "Case " << t << ": ";
solve();
}
// for(int i = 1; i <= 50; i++) {
// for(int j = i; j <= 50; j++) {
// solve(i, j);
// }
// }
}