#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ans = 1;
  for (int i = 6; i <= n; i++) {
    if (n % i == 0) {
      int k1 = 0, k0 = 0;
      int f = 0;
      int x = i;
      while (x > 1 and f == 0) {
        int x2 = x % 2;
        if (x2 == 1 and k0 > 0)
          k1++;
        else if (x2 == 0 and k1 == 0)
          k0++;
        else
          f = 1;
        x /= 2;
      }
      if (k1 - k0 == 0 and f == 0) ans = i;
    }
  }
  cout << ans;
  return 0;
}
