#include <bits/stdc++.h>
using namespace std;
const int p = 1e9 + 7;
const int lim = 2004;
void pre_io() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int32_t main() {
  pre_io();
  long long n;
  cin >> n;
  int j = 1;
  long long res = 1;
  bool doable = true;
  while (doable) {
    long long divisor = ((1LL << j) - 1) * (1LL << (j - 1));
    if (divisor > n) break;
    if (n % divisor == 0) res = divisor;
    j++;
  }
  cout << res;
}
