import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(read()) x = N S = 0 while x: S += x x //= 2 answer = N+N-S print(answer)