#include <bits/stdc++.h>
using namespace std;
int n;
int two[11];
int b[1000005];
int main() {
  two[0] = 1;
  for (int i = 1; i <= 10; i++) two[i] = two[i - 1] * 2;
  for (int i = 1; i <= 10; i++) b[(two[i] - 1) * (two[i - 1])] = 1;
  scanf("%d", &n);
  for (int i = n; i >= 1; i--) {
    if (n % i == 0) {
      if (b[i]) {
        printf("%d", i);
        return 0;
      }
    }
  }
}
