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