#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<long long> arr;
  vector<long long> S;
  for (int i = 0; i < 30; i++) {
    long long cnt = 2;
    for (int j = 0; j < i; j++) {
      cnt *= 2;
    }
    arr.insert((cnt - 1) * (cnt / 2));
  }
  S.push_back(1), S.push_back(n);
  for (long long i = 2; i * i <= n; i++) {
    if (!(n % i)) {
      S.push_back(i);
      S.push_back(n / i);
    }
  }
  sort(S.begin(), S.end());
  reverse(S.begin(), S.end());
  for (int i = 0; i < S.size(); i++) {
    if (arr.count(S[i])) {
      cout << S[i];
      return 0;
    }
  }
  cout << 1 << endl;
}
