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