n = int(input()) x = n + 1 if (x & (x - 1)) == 0: print(n) else: print(n - 1)