#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a[9] = {1, 6, 28, 120, 496, 2016, 8128, 32640, 130816}, i, n, j;
  cin >> n;
  for (i = 0; a[i] <= n; i++) {
    if (n % a[i] == 0) j = a[i];
  }
  cout << j << "\n";
}
