def binary_search_int(ok, ng, test): """ :param ok: solve(x) = True を必ず満たす点 :param ng: solve(x) = False を必ず満たす点 """ while abs(ok - ng) > 1: mid = (ok + ng) // 2 if test(mid): ok = mid else: ng = mid return ok def f(x): _res=0 for _ in range(k): _res+=x x//=2 return _res ############################################################## import sys input = sys.stdin.readline def test(x): return f(x)<=D D=int(input()) res=float("inf") for k in range(1,60): tmp=binary_search_int(0,10**19,test) if f(tmp)==D: res=min(tmp,res) print(res)