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