#include <bits/stdc++.h>
using namespace std;
int Set(int N, int pos) { return N = N | (1 << pos); }
int reset(int N, int pos) { return N = N & ~(1 << pos); }
bool check(int N, int pos) { return (bool)(N & (1 << pos)); }
int main() {
  int arr[100] = {1, 6, 28, 120, 496, 2016, 8128, 32640};
  int i, j, a, n, b, x, y, ck, t, r, ans, rem, cnt, lo, hi, sum, cs = 1;
  cin >> n;
  for (i = 7; i >= 0; i--) {
    if (n % arr[i] == 0) {
      cout << arr[i] << endl;
      break;
    }
  }
}
