#include using namespace std; long long rec(long long num, long long dis){ if(num > dis){ return -1; } if(num == dis){ return num; } int res1 = rec(num * 2, dis - num); int res2 = rec(num * 2 + 1, dis - num); if(res1 == -1 && res2 == -1){ return -1; } if(res1 == -1){ return res2; } if(res2 == -1){ return res1; } if(res1 < res2){ return res1; }else{ return res2; } } int main(){ long long d; cin >> d; cout << rec(1, d) << endl; return 0; }