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