#include <bits/stdc++.h>
using namespace std;
vector<int> getdiv(int x) {
  vector<int> div;
  for (int i = 1; i <= sqrt(x); i++)
    if (x % i == 0) {
      div.push_back(i);
      if (i * i != x) div.push_back(x / i);
    }
  return div;
}
bool ok(int num) {
  int o = 0, z = 0, p = 0;
  while (num) {
    int cur = num % 2;
    num /= 2;
    if (cur == p && cur == 0) {
      z++;
      continue;
    }
    if (cur == p && cur == 1) {
      o++;
      continue;
    }
    if (cur == 1 && p == 0) {
      o++;
      p = 1;
      continue;
    }
    return false;
  }
  if (z + 1 == o) return true;
  return false;
}
int main() {
  int num;
  cin >> num;
  vector<int> div = getdiv(num);
  sort(div.begin(), div.end());
  for (int i = div.size() - 1; i >= 0; i--) {
    if (ok(div[i])) {
      cout << div[i] << endl;
      return 0;
    }
  }
}
