#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, j, k, x, i;
  cin >> a;
  if (a % 2 == 1) {
    cout << 1 << endl;
    return 0;
  }
  j = 2;
  k = 1;
  x = 1;
  for (i = 0; i <= 10; i++) {
    int m = (j - 1) * k;
    j = j * 2;
    k = k * 2;
    if (m > 0 && a % m == 0) {
      if (m > x) x = m;
    }
  }
  cout << x << endl;
  return 0;
}
