#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
int main() {
  int n;
  cin >> n;
  if (n & 1)
    cout << (n - 1) / 2 << endl;
  else {
    int x = 1;
    while (x <= n) x <<= 1;
    x >>= 1;
    cout << (n - x) / 2 << endl;
  }
}
