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