#include <bits/stdc++.h>
using namespace std;
int ans[1000];
const int N = 1e5;
int powm(int a, int n) {
  int base = 1;
  while (n) {
    if (n & 1) base = base * a;
    a = a * a;
    n >>= 1;
  }
  return base;
}
int main() {
  int TOP;
  for (int i = 1;; i++) {
    ans[i] = (powm(2, i) - 1) * powm(2, i - 1);
    if (ans[i] > N) {
      TOP = i;
      break;
    }
  }
  int n;
  while (cin >> n)
    for (int i = TOP; i >= 0; i--) {
      if (n % ans[i] == 0) {
        cout << ans[i] << endl;
        break;
      }
    }
}
