#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, tmp, k, gbd;
  cin >> n;
  k = 1;
  while (k < 10) {
    tmp = pow(2, k - 1) * (pow(2, k) - 1);
    if (n % tmp == 0) gbd = tmp;
    k++;
  }
  cout << gbd;
}
