#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, deg = 1, count = 0, ans;
  cin >> n;
  for (int k = 1; count < n; k++) {
    deg *= 2;
    count = (deg - 1) * (deg / 2);
    if (!(n % count)) ans = count;
  }
  cout << ans;
}
