#include using namespace std; int main() { int64_t n; cin >> n; int64_t ans = 0, m = n; while (m) { ans += m; m /= 2; } cout << 2 * n - ans << endl; }