#include <bits/stdc++.h>
using namespace std;
int main() {
  int num = 0;
  cin >> num;
  int temp = 1;
  int chart[8] = {1, 6, 28, 120, 496, 2016, 8128, 32640};
  for (int i = 7; i >= 0; i--) {
    if (num >= chart[i] && num % chart[i] == 0) {
      temp = chart[i];
      break;
    }
  }
  cout << temp;
  return 0;
}
