#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
int main() {
  v.push_back(1);
  long long x, i, xx = 10, c = 2, cc = 0;
  while (1) {
    i = 1;
    cc = c - 1;
    xx = 0;
    while (i <= c) {
      xx = xx + pow(2, cc);
      cc++;
      i++;
    }
    c++;
    if (xx <= 100000) {
      v.push_back(xx);
    } else {
      break;
    }
  }
  int sz = v.size();
  long long nn;
  cin >> nn;
  for (int ii = sz - 1; ii >= 0; ii--) {
    if (v[ii] <= nn && nn % v[ii] == 0) {
      cout << v[ii] << endl;
      return 0;
    }
  }
  return 0;
}
