#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int inf = 1791791791;
int main() {
  long long n;
  scanf("%lld", &n);
  for (int i = 20; i >= 1; i--) {
    long long val = 1ll << (long long)i;
    val--;
    val *= (1ll << ((long long)(i - 1)));
    if (n % val == 0) {
      printf("%lld\n", val);
      return 0;
    }
  }
  return 0;
}
