#include using namespace std; int main(){ long N; cin >> N; long out_nums = 1; for(long i = N; i != 0; i /= 2){ out_nums *= i % 2 + 1; } cout << N + 1 - out_nums << endl; }