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