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