#include <bits/stdc++.h>
using namespace std;
long long int pi[1000], ai[1000];
long long int bsearch(long long int arr[], long long int x, long long int n) {
  long long int a = 0;
  long long int k;
  long long int b = n - 1;
  while (a <= b) {
    k = (a + b) / 2;
    if (arr[k] == x) {
    }
    if (arr[k] > x)
      b = k - 1;
    else
      a = k + 1;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int i, j, k = 0, m = 0, n, f = 0, r1 = 0, r2 = 0, r3 = 0, r4 = 0,
                      f1 = 0, f2 = 0, c1 = 0, c2 = 0, c3 = 0, c4 = 0, k1 = 0,
                      k2 = 0, j1, j2;
  cin >> n;
  for (i = 1; i <= n; i++) {
    if (n % i == 0) {
      f1 = n / i;
      j1 = (long long int)(log2(i * 1.0));
      j2 = (long long int)(log2(f1 * 1.0));
      for (; j1 >= 0; j1--) {
        if (i & (1 << j1) && r2 == 0) {
          c1++;
          if (j1 == 0 && c2 == c1 - 1) {
            k1 = max(k1, i);
          }
        } else if (!(i & (1 << j1))) {
          c2++;
          r2 = 1;
          if (j1 == 0 && c2 == c1 - 1) {
            k1 = max(k1, i);
          }
        } else
          break;
      }
      for (; j2 >= 0; j2--) {
        if (f1 & (1 << j2) && r4 == 0) {
          c3++;
          if (j2 == 0 && c3 - 1 == c4) {
            k2 = max(k2, f1);
          }
        } else if (!(f1 & (1 << j2))) {
          r4 = 1;
          c4++;
          if (j2 == 0 && c3 - 1 == c4) {
            k2 = max(k2, f1);
          }
        } else
          break;
      }
      r3 = 0;
      r1 = 0;
      r2 = 0;
      r4 = 0;
      c1 = 0;
      c2 = 0;
      c3 = 0;
      c4 = 0;
    }
  }
  cout << max(k1, k2);
  return 0;
}
