#include <bits/stdc++.h>
int two[20];
int main() {
  two[0] = 1;
  for (int i = 1; i < 20; i++) two[i] = two[i - 1] * 2;
  int n, ans;
  scanf("%d", &n);
  for (int k = 1; k < 11; k++) {
    int now = two[k - 1] * (two[k] - 1);
    if (n % now == 0) ans = now;
  }
  printf("%d\n", ans);
}
