#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, res = 0;
  cin >> n;
  for (int i = 1; i < 10; ++i) {
    if (n % (((1 << i) - 1) * (1 << (i - 1))) == 0) {
      res = ((1 << i) - 1) * (1 << (i - 1));
    }
  }
  cout << res << endl;
}
