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