#include #include #include #include #define llint long long using namespace std; llint n; int main(void) { cin >> n; assert(n >= 1 && n < (1LL<<60)); vector vec; for(llint t = n; t; t = (t-1)&n) vec.push_back(t); sort(vec.begin(), vec.end()); cout << vec[(int)vec.size()/2] << endl; return 0; }