#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  long long int n;
  cin >> n;
  long long int res = log(0.5 * (1 + sqrt(1 + 8 * n))) / log(2) + 1;
  long long int temp = ((pow(2, res) - 1) * (pow(2, res - 1)));
  while (n % temp != 0) {
    --res;
    temp = ((pow(2, res) - 1) * (pow(2, res - 1)));
    if (res == 1) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << temp << endl;
  return 0;
}
