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