#include <bits/stdc++.h>
using namespace std;
int tmp[15];
int main() {
  for (int i = 1; i <= 10; i++) tmp[i] = ((1 << i) - 1) * (1 << (i - 1));
  int n;
  cin >> n;
  for (int i = n; i >= 1; i--) {
    if (n % i == 0) {
      for (int j = 10; j >= 1; j--) {
        if (tmp[j] == i) {
          cout << i << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}
