#include <bits/stdc++.h>
using namespace std;
long long N;
int main(void) {
  cin >> N;
  if (N % 2 == 0) {
    long long k;
    for (long long i = ((long long)0); i < ((long long)60); i++)
      if ((1LL << i) & N) k = i;
    N -= (1LL << k);
  }
  cout << N / 2 << endl;
}
