#include <bits/stdc++.h>
using namespace std;
bool check(long long n) {
  int cnt0 = 0;
  int cnt1 = 0;
  while (n % 2 == 0 && n > 0) {
    cnt0++;
    n >>= 1;
  }
  while (n % 2 == 1) {
    cnt1++;
    n >>= 1;
  }
  if (n != 0) return false;
  if (cnt0 + 1 == cnt1) return true;
  return false;
}
int main() {
  long long n;
  cin >> n;
  set<long long> div;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      div.insert(i);
      div.insert(n / i);
    }
  }
  long long ans = 0;
  for (auto x : div) {
    if (check(x)) {
      ans = max(ans, x);
    }
  }
  cout << ans << endl;
  return 0;
}
