#include <bits/stdc++.h>
using namespace std;
long long solve(long long k) {
  long long ans = 1, j = 2;
  while (k != 0) {
    if (k % 2 == 0) {
      j *= 2;
      k /= 2;
    } else {
      ans *= j;
      k--;
    }
  }
  return ans;
}
int main() {
  long long t, n, m, i, j, k;
  cin >> n;
  long long ans = 1;
  for (i = 2;; i++) {
    k = solve(i);
    j = (k - 1) * k;
    j /= 2;
    if (j > n) break;
    if (n % j == 0) ans = j;
  }
  cout << ans;
}
