def distance(d0, n): res = 0 for i in range(n): res += d0 d0 //= 2 return res def good(d, n): l, r = 0, d + 1 while r - l > 1: mid = (l + r) // 2 d_res = distance(mid, n) if d_res == d: return mid elif d_res < d: l = mid else: r = mid return None d = int(input()) for i in range(60, 0, -1): d_res = good(d, i) if d_res: print(d_res) break