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