#include <bits/stdc++.h>
int main() {
  long long int n, i = 0, p = 0, fun = 0, s = 0, a, b;
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) {
    if (n % i == 0) {
      s = 0;
      for (p = 1; s < i; p++) {
        a = pow(2, p);
        b = pow(2, p - 1);
        s = (a - 1) * b;
        if (s == i) break;
      }
      if (s == i) fun = s;
    }
  }
  printf("%lld\n", fun);
  return 0;
}
