#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
string FILENAME;
const int inf = (int)1e9 + 5;
const long long INF = (long long)1e18 + 5;
vector<long long> get_bin(long long x) {
  vector<long long> res;
  while (x > 0) {
    res.push_back(x % 2);
    x /= 2;
  }
  reverse(res.begin(), res.end());
  return res;
}
void solve() {
  long long n;
  cin >> n;
  long long ans = -1;
  for (long long i = 1; i <= n; i++) {
    if (n % i != 0) continue;
    auto bin = get_bin(i);
    if (bin.size() % 2 == 0) continue;
    long long k = bin.size() / 2;
    bool good = true;
    for (long long j = 0; j < k + 1; j++)
      if (bin[j] != 1) good = false;
    for (long long j = k + 1; j < bin.size(); j++)
      if (bin[j] != 0) good = false;
    if (good) ans = i;
  }
  cout << ans;
}
int main() {
  string filename = "";
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(15);
  solve();
  (void)0;
  return 0;
}
