#include <bits/stdc++.h>
using namespace std;
long long int n, ans, fn, num, on, x, y;
bool check(long long int a) {
  x = 1 << ans;
  y = (1 << (ans + 1)) - 1;
  if (!(on % x)) {
    if (!((on / x) % y))
      return true;
    else
      return false;
  }
  return false;
}
int main() {
  cin >> n;
  fn = 1;
  ans = 0;
  on = n;
  while (!(n % 2)) {
    ans++;
    if (check(ans)) fn = x * y;
    n /= 2;
  }
  cout << fn << "\n";
  return 0;
}
