#include #define MOD 1000000007LL using namespace std; typedef long long ll; typedef pair P; ll dp[3001][3001]; ll func(ll n){ if(n<=1LL)return 0; if(n%2LL==0LL){ return func(n/2LL)+n/2LL; }else{ return 2LL*func((n-1LL)/2LL); } } int main(void){ ll n; scanf("%lld",&n); printf("%lld\n",func(n)); return 0; }