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