#include using namespace std; int main(int argc, const char* argv[]) { size_t N; cin >> N; size_t normal = 0; size_t ideal = 0; size_t tmp = N; while (tmp > 0) { if (ideal < normal + tmp * 2) { ideal = normal + tmp * 2; } normal += tmp; tmp >>= 1; } cout << ideal - normal << endl; return 0; }