#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ans;
  int arr[9] = {1, 6, 28, 120, 496, 2016, 8128, 32640, 130816};
  cin >> n;
  for (int i = 0; i < 9; i++) {
    if (n % arr[i] == 0) {
      ans = arr[i];
    }
  }
  cout << ans << endl;
  return 0;
}
