#include <bits/stdc++.h>
using namespace std;
int const N = 2e5 + 5;
vector<long long> v;
int arr[N];
long long x = 1, y, z, n, m;
int main() {
  cin >> y;
  for (int i = 0; i < 20; i++) {
    arr[i] = x;
    x *= 2;
  }
  m = 0;
  for (int i = 0; i < 15; i++) {
    n = 0;
    for (int j = i; j < i + i + 1; j++) {
      n += arr[j];
    }
    v.push_back(n);
  }
  for (int i = v.size() - 1; i >= 0; i--) {
    if (y % v[i] == 0) {
      cout << v[i] << endl;
      return 0;
    }
  }
  return 0;
}
