#include using namespace std; int main() { long long n; cin >> n; long long t = 0, a = n * 2; while(n > 0){ t += n; n /= 2; } cout << a - t << endl; return 0; }