#include <bits/stdc++.h>
using namespace std;
bool ck(int n) {
  int a = sqrt(n * 2);
  if (__builtin_popcount(a + 1) == 1 && (a + 1) * a == n * 2) return 1;
  return 0;
}
int main() {
  int n, res = 1;
  cin >> n;
  for (int a = 1; a * a <= n; a++) {
    if (n % a == 0) {
      if (ck(a)) res = max(res, a);
      if (ck(n / a)) res = max(res, n / a);
    }
  }
  cout << res << endl;
  return 0;
}
