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