#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  if (n % 32640 == 0) {
    cout << 32640;
  } else if (n % 8128 == 0) {
    cout << 8128;
  } else if (n % 2016 == 0) {
    cout << 2016;
  } else if (n % 496 == 0) {
    cout << 496;
  } else if (n % 120 == 0) {
    cout << 120;
  } else if (n % 28 == 0) {
    cout << 28;
  } else if (n % 6 == 0) {
    cout << 6;
  } else {
    cout << 1;
  }
  return 0;
}
