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