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