N = int(input()) A, B = N * 2, N while N > 0: N //= 2 B += N print(A - B)