N = int(input()) i = 1 while True: if (i << 1) > N: print(2 * (N - i)) break i <<= 1