#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  if (n % 2 == 0) {
    n -= (1 << (int)log2(n)) - 1;
  }
  cout << n / 2 << endl;
}
