#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  long long int arr[8] = {1, 6, 28, 120, 496, 2016, 8128, 32640};
  for (int i = 7; i >= 0; i--) {
    if (n % arr[i] == 0) {
      cout << arr[i];
      break;
    }
  }
  return 0;
}
