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