#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i;
  cin >> n;
  long long n1 = n;
  long long cou = 0;
  while (n1 > 0) {
    cou++;
    n1 /= 2;
  }
  long long k = cou / 2 + cou % 2;
  long long num = 1;
  while (k > 0) {
    long long num1 = pow(2, k);
    long long num2 = pow(2, k - 1);
    num = (num1 - 1) * num2;
    if (num <= n && n % num == 0) break;
    k--;
  }
  cout << num << endl;
  return 0;
}
