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