#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
const int N = 1e5 + 123;
int n, a[101], t;
priority_queue<int> ans;
vector<int> u;
int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << 1;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (n % i == 0) ans.push(i);
  }
  int j = 0, res = 0, k = 0;
  for (int i = 1; i <= n; i++) {
    if ((pow(2, j) - 1) * pow(2, j - 1) <= n)
      res = (pow(2, j) - 1) * pow(2, j - 1), j++, u.push_back(res);
  }
  int cnt = -N;
  for (int i = (int)(u.size()) - 1; i >= 0;) {
    if (ans.empty()) break;
    if (u[i] == ans.top()) {
      cnt = max(cnt, ans.top());
      ans.pop();
    }
    if (u[i] > ans.top()) i--;
    if (u[i] < ans.top()) ans.pop();
  }
  cout << cnt << endl;
}
