import math def normal(n): if n == 0: return 0 return n + normal(math.floor(n / 2)) n = int(input()) print(abs(n * 2 - normal(n)))