N = int(input()) t = 0 x = N while x != 0: t += x x //= 2 print(2*N-t)