#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ans, num;
  scanf("%d", &n);
  for (int i = 17; i >= 1; i--) {
    num = (pow(2, i) - 1) * pow(2, i - 1);
    if (n % num == 0) {
      ans = num;
      break;
    }
  }
  printf("%d\n", ans);
}
