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