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