#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  if (n % 2 == 1) cout << (n - 1) / 2;
  int base = 1, cnt = 0, duliu = n;
  if (n % 2 == 0) {
    for (; duliu >= base; cnt++) {
      base *= 2;
    }
    cout << (duliu - base / 2) / 2 << endl;
  }
  return 0;
}
