#include <bits/stdc++.h>
using namespace std;
bool isBeautiful(int n) {
  int k = 0;
  while (n % 2 == 0) {
    n /= 2;
    ++k;
  }
  int x = pow(2, k + 1) - 1;
  return x == n;
}
int main() {
  int n;
  cin >> n;
  long long ans = 1;
  if (isBeautiful(n)) {
    cout << n << endl;
    return 0;
  }
  for (int i = 2; i * i <= n; ++i) {
    if (n % i) continue;
    if (isBeautiful(n / i)) {
      ans = n / i;
      break;
    }
    if (isBeautiful(i)) {
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}
