#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, a[15], ans;
  a[0] = 1;
  for (int i = 1; i < 15; i++) {
    a[i] = a[i - 1] << 1;
    a[i] += 1 << (2 * i);
  }
  cin >> n;
  for (int i = 14; i >= 0; i--)
    if (n % a[i] == 0) {
      ans = a[i];
      break;
    }
  cout << ans;
  return 0;
}
