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