#include <bits/stdc++.h>
using namespace std;
long long int solve(long long int n) {
  long long int m = n, x = 1;
  while (m % 2 == 0) {
    m = m / 2;
    x = x * 2;
  }
  while (x) {
    if (n % ((2 * x - 1) * x) == 0) return ((2 * x - 1) * x);
    x = x / 2;
  }
  return 1;
}
int main() {
  long long int n;
  cin >> n;
  cout << solve(n) << endl;
}
