#include <bits/stdc++.h>
using namespace std;
typedef int arr[100010];
arr pp, p, nnum, num;
int n, k, cnt;
inline int find(int k) {
  int x = (1 << k) - 1;
  int cc = 0;
  for (int i = 2; 1LL * i * i <= x; i++)
    if (x % i == 0) {
      pp[++cc] = i;
      nnum[cc] = 0;
      while (x % i == 0) nnum[cc]++, x /= i;
    }
  if (x > 1) pp[++cc] = x, nnum[cc] = 1;
  for (int i = 1, j = 1; i <= cc; i++) {
    while (j <= cnt && p[j] != pp[i]) j++;
    if (j > cnt || num[j] < nnum[i]) return 0;
  }
  return (1 << k) - 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 2; 1LL * i * i <= n; i++)
    if (n % i == 0) {
      p[++cnt] = i;
      while (n % i == 0) num[cnt]++, n /= i;
    }
  if (n > 1) p[++cnt] = n, num[cnt] = 1;
  if (p[1] == 2)
    k = num[1];
  else
    k = 0;
  for (; k; k--) {
    num[1] -= k;
    int tt = find(k + 1);
    num[1] += k;
    if (tt) return printf("%d\n", tt * (1 << k)), 0;
  }
  printf("1\n");
  return 0;
}
