#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-9, PI = acos(-1.);
const int INF = 0x3f3f3f3f, MOD = 1e9 + 7;
const int N = 1e5 + 5;
int n;
int main() {
  scanf("%d", &n);
  long long ans = 0;
  for (int i = 1;; i++) {
    long long d = ((1ll << i) - 1) * (1ll << (i - 1));
    if (d > n) break;
    if (n % d == 0) ans = d;
  }
  printf("%lld\n", ans);
  return 0;
}
