#include <bits/stdc++.h>
using namespace std;
bool isSubSequence(string str1, string str2, int m, int n) {
  int j = 0;
  for (int i = 0; i < n && j < m; i++) {
    if (str1[j] == str2[i]) j++;
  }
  return (j == m);
}
int isPrime(long long n) {
  for (int i = 2; i < sqrt(n); i++)
    if (n % i == 0) return 0;
  return 1;
}
int isSquare(long long n) { return (long long)sqrt(n) * (sqrt(n)) == n; }
long long powcal(long long k) { return (pow(2, k) - 1) * (pow(2, k - 1)); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin.tie(NULL);
  long long int i = 1, j, n, k = 1, p = 0, cnt = 0, l = 1, ans;
  cin >> n;
  if (n == 1) return cout << 1, 0;
  while (l <= n / 2) {
    l = powcal(i);
    if (n % l == 0) ans = l;
    i++;
  }
  cout << ans;
  return 0;
}
