#include int main() { long long int n, ans; scanf("%lld", &n); ans = n * 2; while(n) { ans -= n; n /= 2; } printf("%lld\n", ans); return 0; }