#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  if (n % 2 == 1) {
    cout << (n - 1) / 2 << endl;
  } else {
    long long x = 1;
    while (2 * x <= n) {
      x *= 2;
    }
    cout << (n - x) / 2 << endl;
  }
  return 0;
}
