#include <bits/stdc++.h>
using namespace std;
long long n, kofa = 1, formula, sol;
inline long long kvad(long long x) { return x * x; }
long long pot(long long a, long long n) {
  if (n == 0) return 1;
  if (n % 2 == 0)
    return kvad(pot(a, n / 2));
  else
    return kvad(pot(a, n / 2)) * a;
}
int main() {
  scanf("%lld", &n);
  while (formula < n) {
    formula = (pot(2, kofa) - 1) * (pot(2, kofa - 1));
    if (n % formula == 0) sol = formula;
    kofa++;
  }
  printf("%lld\n", sol);
  return 0;
}
