#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define pb push_back
using ll = long long;
// #define int ll
using pi = array<int, 2>;
using ti = array<int, 3>;

int find_number(int MAX) {
  int x = MAX + 1;
  for (int h = (1 << 30); h >= 1; h /= 2) {
    if (x - h <= 0) continue;
    if (smaller(x - h)) {
      x -= h;
    }
  }
  return x - 1;
}
