#include <bits/stdc++.h>
using namespace std;
vector<int> divisors;
int binPow(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x;
    y >>= 1;
    if (y) x = x * x;
  }
  return (int)res;
}
void printDivisors(int n) {
  for (int i = 1; i <= sqrt(n) + 1; i++) {
    if (n % i == 0) {
      if (n / i == i) {
        divisors.push_back(i);
      } else {
        divisors.push_back(i);
        divisors.push_back(n / i);
      }
    }
  }
}
int main() {
  int n;
  cin >> n;
  printDivisors(n);
  int ans = 0;
  for (int i = 0; i < divisors.size(); i++) {
    int one = 0, zero = 0;
    bool in = false;
    for (int j = 1; j < 32; j++) {
      int a = binPow(2, j) - 1;
      int b = binPow(2, j - 1);
      if ((a * b) == divisors[i]) {
        ans = max(ans, divisors[i]);
      }
    }
  }
  cout << ans;
}
