#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  if (n % 2) {
    cout << (n - 1) / 2 << endl;
  } else {
    int m = 2;
    while (m <= n) m <<= 1;
    m /= 2;
    printf("%d\n", (n - m) / 2);
  }
  return 0;
}
