#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 1;
  for (long long i = 2; (pow(2, i) - 1) * pow(2, i - 1) <= n; ++i)
    if ((n % (((long long)pow(2, i) - 1) * (long long)pow(2, i - 1))) == 0)
      ans = (((long long)pow(2, i) - 1) * (long long)pow(2, i - 1));
  cout << ans << endl;
  ;
  ;
}
