#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a = 1, k, i = -1;
  cin >> n;
  while (a <= n) {
    if (n % a == 0) k = a;
    i += 2;
    ;
    a += pow(2, i);
    a <<= 1;
  }
  cout << k;
}
