#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int k = 1;
  int ans = 1;
  while (true) {
    int temp = (std::pow(2, k) - 1) * (pow(2, k - 1));
    if (temp > n) break;
    if (n % temp == 0) ans = temp;
    k++;
  }
  cout << ans << endl;
}
