#include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; ll N, M, sum; int main() { cin >> N; M = N; while (M > 0) { sum += M; M /= 2; } cout << 2 * N - sum << endl; return 0; }