#include <bits/stdc++.h>
using namespace std;
long long n;
long long A[35], mk[100010];
long long qpow(long long base, long long exp) {
  long long ans = 1;
  for (long long i = 1; i <= exp; i++) ans *= 2;
  return ans;
}
int main() {
  cin >> n;
  long long lg = 63 - __builtin_clzll(n);
  for (long long i = 1; i <= 10; i++) {
    A[i] = ((1ll << i) - 1ll) * (1 << (i - 1));
    if (A[i] > 100000) break;
    mk[A[i]] = 1;
  }
  for (long long i = n; i >= 1; i--) {
    if (n % i == 0 && mk[i]) {
      cout << i;
      return 0;
    }
  }
  return 0;
}
