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