n=int(input()) a=2*n c=0 while n>0: c+=n n//=2 print(a-c)