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