N = int(input()) pow = [2 ** i for i in range(100)] k = 0 while pow[k] < N: k += 1 print(pow[k] - N + k)