#include int main(void) { unsigned long long int n,k,l=0; scanf("%llu",&n); k = n; while(k){l+=k;k/=2;} printf("%llu\n",2*n-l); return 0; }