#include <bits/stdc++.h>
using namespace std;
void solve() {}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  long long k = 1;
  vector<long long> v;
  while (1) {
    long long tmp = ((1 << k) - 1) * (1 << (k - 1));
    if (tmp > 100001) break;
    v.push_back(tmp);
    k++;
  }
  while (t--) {
    long long n;
    cin >> n;
    for (int i = (int)v.size() - 1; i > -1; i--) {
      if (n % v[i] == 0) {
        cout << v[i] << "\n";
        break;
      }
    }
  }
  return 0;
}
