n = int(input()) half, double = 0, n while n > 0: half += n n //= 2 double *= 2 print(abs(half - double))