#include <bits/stdc++.h>
using namespace std;
vector<int> v;
bool isGood(int x) {
  int o = 0, z = 0;
  int lastOne = -1;
  for (int i = 0; i <= 31; ++i)
    if ((x & (1 << i)) > 0) lastOne = i;
  for (int i = 0; i <= lastOne; ++i) {
    if ((x & (1 << i)) == 0 && o == 0) {
      ++z;
    } else if ((x & (1 << i)) > 1) {
      ++o;
    } else {
      return false;
    }
  }
  return z + 1 == o;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      if (i * i == n)
        v.push_back(i);
      else {
        v.push_back(i);
        v.push_back(n / i);
      }
    }
  }
  int ans = 1;
  for (auto it : v) {
    if (ans < it && isGood(it)) ans = it;
  }
  cout << ans << endl;
  return 0;
}
