n=int(input()) m=n sum=0 while n!=0: sum+=n n//=2 print(m*2-sum)