#include <bits/stdc++.h>
using namespace std;
const int MAX_NUM = 100000;
int n;
int pow(int a, int b) {
  int r = 1, base = a;
  while (b) {
    if (b & 1) r *= base;
    base *= base;
    b >>= 1;
  }
  return r;
}
int main() {
  cin >> n;
  int bn = 1;
  int ans = 1;
  for (int i = 1; (pow(2, i) - 1) * pow(2, i - 1) <= n; i++) {
    bn = (pow(2, i) - 1) * pow(2, i - 1);
    if (n % bn == 0) {
      ans = bn;
    }
  }
  cout << ans << '\n';
}
