#include <bits/stdc++.h>
const int nmax = 2e5 + 3;
const int inf = 1e5 + 3;
const int mod = 1000003;
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  unsigned long long first = 1, ans, a = 1, b = 1;
  ;
  while (first <= n) {
    if (n % first == 0) ans = first;
    a = a * 2 + 1;
    b *= 2;
    first = a * b;
  }
  cout << ans;
}
