#include <bits/stdc++.h>
using namespace std;
int a[] = {1, 6, 28, 120, 496, 2016, 8128, 32640};
int n;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 7; i > -1; --i) {
    if (n % a[i] == 0) {
      cout << a[i];
      return 0;
    }
  }
  return 0;
}
