#include <bits/stdc++.h>
using namespace std;
int a[100000];
int main() {
  int n, x, j(0);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    double y = (pow(2.0, i) - 1) * (pow(2.0, (i - 1)));
    x = (int)y;
    if (x < y) x++;
    a[j++] = x;
    if (x > n) break;
  }
  for (int i = j - 1; i >= 0; i--) {
    if (n % a[i] == 0) {
      printf("%d\n", a[i]);
      return 0;
    }
  }
  return 0;
}
