n = int(input()) A = 0 i = n while i > 0: A += i i //= 2 print(n*2-A)