n = int(input()) k = n num1 = 0 num2 = 2 * n while k > 0: num1 += k k = k // 2 print(num2 - num1)