#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)1e9 + 7;
const long long maxn = (long long)1e5 + 7;
const long long maxe = (long long)1e6 + 7;
const long long INF = (long long)1e9 + 7;
const double PI = acos(-1);
int dx[4] = {0, 0, 1, -1};
int dy[4] = {-1, 1, 0, 0};
bool ok(int x) {
  vector<int> t;
  while (x) {
    t.push_back(x & 1);
    x >>= 1;
  }
  if (t.size() % 2 == 0) return false;
  int k = t.size() / 2;
  for (int i = 0; i < k; i++)
    if (t[i] != 0) return false;
  for (int i = k; i < t.size(); i++)
    if (t[i] != 1) return false;
  return true;
}
int main() {
  int n;
  cin >> n;
  for (int i = n; i >= 1; i--) {
    if (n % i == 0 && ok(i)) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}
