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