#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v;
  for (int i = 1; i <= 20; ++i) {
    int first = ((1 << i) - 1) * (1 << (i - 1));
    if (first > 1e5) break;
    v.push_back(first);
  }
  for (int i = v.size() - 1; i >= 0; --i) {
    if (n % v[i] == 0) return cout << v[i], 0;
  }
  return 0;
}
