#include <bits/stdc++.h>
using namespace std;
int n, p[25];
set<int> s;
void init() {
  p[0] = 1;
  for (int i = 1; i <= 20; i++) {
    p[i] = p[i - 1] * 2;
    s.insert((p[i] - 1) * (p[i - 1]));
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  init();
  while (cin >> n) {
    int ans;
    for (int i = 1; i <= n; i++) {
      if (n % i == 0 && s.count(i)) ans = i;
    }
    cout << ans << endl;
  }
  return 0;
}
