#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      v.push_back(i);
      if (i != n / i) {
        v.push_back(n / i);
      }
    }
  }
  sort(v.begin(), v.end());
  int ans = 0;
  for (int i = v.size() - 1; i > -1; i--) {
    int p = v[i];
    int q = 0;
    while (p % 2 == 0) {
      q++;
      p /= 2;
    }
    int r = pow(2, q + 1) + 0.5;
    r--;
    if (p == r) {
      ans = v[i];
      break;
    }
  }
  cout << ans << endl;
}
