D = int(input()) for d in range(100): t = D // 2 + d now = 0 while now < D and t: now += t t //= 2 if now == D: print(D // 2 + d) exit() print(D)