#include <bits/stdc++.h>
int a[53];
int check(int x) {
  a[50];
  int p = 0, j;
  for (j = 0; j <= 50; j++) {
    a[j] = 0;
  }
  j = 0;
  while (x) {
    a[j] = x % 2;
    x = x / 2;
    p++;
    j++;
  }
  if (p % 2 == 0) return 0;
  for (j = 0; j < p / 2; ++j) {
    if (a[j] == 1) return 0;
  }
  for (j = p / 2; j < p; ++j) {
    if (a[j] == 0) return 0;
  }
  return 1;
}
int main() {
  int n, i;
  scanf("%d", &n);
  for (i = n; i > 0; i--) {
    if (n % i == 0) {
      if (check(i)) {
        printf("%d\n", i);
        return 0;
      }
    }
  }
}
