#include using namespace std; #define ULL unsigned long long int main() { ULL N; cin >> N; ULL def = N, sp = N * 2; while( N != 0 ) { N /= 2; def += N; } cout << max( def, sp ) - min( def, sp ) << endl; return 0; }