#include <bits/stdc++.h>
using std::cin;
using std::cout;
inline int lowbit(int x) { return x & -x; }
int main() {
  int n, x;
  cin >> n;
  if (n & 1)
    cout << n / 2;
  else {
    for (x = n; x ^ lowbit(x); x -= lowbit(x))
      ;
    n -= x;
    cout << n / 2;
  }
  return 0;
}
