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