n=int(input()) ans=0 ans2=n*2 while n: ans+=n n//=2 print(ans2-ans)