N = int(input()) X = N * 2 Y = 0 while N: Y += N N //= 2 print(X - Y)