D = int(input()) l = 0 r = D while r - l > 1: m = (r + l) // 2 cnt = 0 x = m while x: cnt += x x //= 2 if cnt < D: l = m else: r = m for i in range(10**6): x = r + i tmp = x dist = 0 while True: dist += x if dist >= D: break x //= 2 if D == dist: break print(tmp)