#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k = 1, div = 1;
  long long ts;
  cin >> n;
  ts = 1;
  while (ts <= n) {
    if (n % ts == 0) {
      div = ts;
    }
    ts = pow(2, k - 1) * (pow(2, k) - 1);
    k++;
  }
  cout << div;
  return 0;
}
