N = int(input()) sm = 0 la = N * 2 while N > 0: sm += N N //= 2 print(la - sm)