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