#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int convert(string s) {
  reverse(s.begin(), s.end());
  int r = 0;
  for (int i = 0; i < (int)s.size(); i++) {
    r += (s[i] - 48) * pow(2, i);
  }
  return r;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  scanf("%d", &n);
  int mi = 1;
  int r = 1;
  int cn = 1;
  while (r < n) {
    if (r > n / 2) break;
    string s = "";
    for (int i = 1; i <= cn; i++) s += "1";
    for (int i = 1; i < cn; i++) s += "0";
    int deci = convert(s);
    cn++;
    if (n % deci == 0) mi = max(mi, deci);
    r = deci;
  }
  printf("%d\n", mi);
  return 0;
}
