n = int(input()) x = 0 m = n while m: x += m m //= 2 print(abs(x - n*2))