#include <bits/stdc++.h>
using namespace std;
int A[1000];
int main() {
  int n;
  cin >> n;
  int two = 1;
  while (two <= n) two *= 2;
  two /= 2;
  cout << (n % 2 ? (n - 1) / 2 : (n - two) / 2) << endl;
}
