#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int a[10] = {0};
  for (int i = 1; i <= 10; i++) {
    a[i] = (pow(2, i) - 1) * pow(2, i - 1);
  }
  while (cin >> n) {
    for (int i = 9; i >= 1; i--)
      if (n % a[i] == 0) {
        cout << a[i] << endl;
        break;
      }
  }
  return 0;
}
