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