def popcount(n): cnt = 0 while n: cnt += n & 1 n >>= 1 return cnt N = int(input()) c = popcount(N) // 2 for i in range(65): if (N >> i) & 1 and c: N -= 1 << i c -= 1 print(N)