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