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