#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[100000];
  int k = 0, j = 0;
  while (1) {
    int x = (int)pow(2, 2 * k + 1) - (int)pow(2, k);
    if (x > n) break;
    arr[j++] = x;
    k++;
  }
  k = j - 1;
  while (k >= 0) {
    if (n % arr[k] == 0) {
      cout << arr[k];
      return 0;
    }
    k--;
  }
}
