#include <bits/stdc++.h>
bool fine(int v) {
  int z = 0, s = 0;
  while ((v & 1) == 0) {
    z++;
    v >>= 1;
  }
  while ((v & 1) == 1) {
    s++;
    v >>= 1;
  }
  return v == 0 && z == s - 1;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = n; i >= 1; i--) {
    if (n % i == 0 && fine(i)) {
      printf("%d", i);
      return 0;
    }
  }
}
