#include using namespace std; int main(){ int A, B; cin >> A >> B; int bit = 1; while(bit * 2 <= A + 1)bit *= 2; cout << min(bit - 1, B) << endl; }