#include using namespace std; #define PI 4*atan(1) #define INF 1e8 typedef long long ll; typedef unsigned long long ull; int dx[4] = {1,0,-1,0}; int dy[4] = {0,1,0,-1}; int main(){ ull N; cin >> N; ull ans = 0; ull n = N * 2; while(1){ ans += N; N /= 2; if(N == 0)break; } cout << n - ans << endl; }