# include using namespace std; typedef long long ll; ll n, sum; ll ksm(ll x, ll y) { ll res; res = 1; while (y) { res = (y & 1) ? res * x : res; x = x * x; y >>= 1; } return res; } int main() { scanf("%lld", &n); sum = n; for (int i = 1; i <= log2(n); i++) sum -= n / ksm(2, i); printf("%lld\n", sum); return 0; }