#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
int main() {
  long long n;
  cin >> n;
  for (int i = n; i >= 0; i--) {
    if (n % i != 0) continue;
    vector<int> bin;
    long long x = i;
    while (x) {
      bin.push_back(x % 2);
      x /= 2;
    }
    reverse(bin.begin(), bin.end());
    if (bin.size() % 2 == 0) continue;
    long long half = bin.size() / 2;
    long long sum = 0;
    for (int i = 0; i < half + 1; i++) sum += bin[i];
    if (sum != half + 1) continue;
    sum = 0;
    for (int i = half + 1; i < bin.size(); i++) sum += bin[i];
    if (sum == 0) {
      cout << i << endl;
      return 0;
    }
  }
  cout << 1 << endl;
  return 0;
}
