#include <bits/stdc++.h>
using namespace std;
bool check(long long int n) {
  long long int one = 0, zero = 0, c = 0;
  while (n) {
    long long int k = n % 2;
    if (k == 0) {
      zero++;
    } else {
      break;
    }
    n /= 2;
    c++;
  }
  while (n) {
    long long int k = n % 2;
    if (k == 1) {
      one++;
    } else {
      break;
    }
    n /= 2;
    c++;
  }
  if (one - zero == 1 && n == 0) {
    return true;
  }
  return false;
}
int32_t main() {
  long long int n, i;
  cin >> n;
  for (i = n; i >= 0; i--) {
    if (n % i == 0 && check(i)) {
      break;
    }
  }
  cout << i;
  return 0;
}
