#include <bits/stdc++.h>
using namespace std;
const int MaxN = 6e2 + 10;
const int MOD = 1e6 + 3;
const int INF = 1e9;
int main() {
  int n;
  cin >> n;
  int x = n;
  if (n % 2 == 1) {
    cout << (n - 1) / 2 << '\n';
  } else {
    int x = n / 2;
    int c = 1;
    while (x > 1) x /= 2, c *= 2;
    cout << n / 2 - c << endl;
  }
  return 0;
}
