#include <bits/stdc++.h>
using namespace std;
const int maxn = 100009;
int a[1009], cnt = 0;
int bna[19];
void init() {
  bna[0] = 1;
  for (int i = 1; i <= 30; i++) {
    bna[i] = bna[i - 1] * 2;
  }
  a[0] = 1, a[1] = 6, a[2] = 28, a[3] = 120, a[4] = 496;
  cnt = 5;
  for (int i = 6; i <= 12; i++) {
    int sum = 0;
    for (int j = i - 1; j < i + i - 1; j++) {
      sum += (bna[j]);
    }
    if (sum == (bna[i] - 1) * (bna[i - 1])) {
      a[cnt++] = sum;
    }
  }
}
int main() {
  int n;
  init();
  while (scanf("%d", &n) != EOF) {
    for (int i = cnt - 1; i >= 0; i--) {
      if (n >= a[i] && n % a[i] == 0) {
        printf("%d\n", a[i]);
        break;
      }
    }
  }
  return 0;
}
