# include # include # include # include # include # include # include # include using namespace std; # define repl(i, a, b) for(int i=(int)(a);i<(int)(b);i++) # define rep(i, n) repl(i, 0, n) typedef long long ll; int main(){ ll n, sum1 = 0, sum2 = 0; cin >> n; int i=0; sum2 += n; while(n != 0){ sum1 += n; if(i == 1) sum2 += n*2; n /= 2; i++; } cout << sum2 - sum1 << endl; return 0; }