#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> v;
  scanf("%d", &n);
  for (int k = 1;; k++) {
    int u = (pow(2, k) - 1) * pow(2, k - 1);
    if (u > 100000)
      break;
    else
      v.push_back(u);
  }
  for (int i = v.size() - 1; i >= 0; i--) {
    if (v[i] <= n && n % v[i] == 0) {
      printf("%d", v[i]);
      return 0;
    }
  }
}
