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