#めぐる式二部探索 #参考サイト:https://aotamasaki.hatenablog.com/entry/meguru_bisect D = int(input()) def is_ok(arg): jump = 0 while arg>0: jump += arg arg = arg//2 return jump >= D def meguru_bisect(ng, ok): while (abs(ok - ng) > 1): mid = (ok + ng) // 2 if is_ok(mid): ok = mid else: ng = mid return ok ans = meguru_bisect(0,10**18 + 1) jump = 0 anstemp = ans while anstemp >0: jump += anstemp anstemp = anstemp//2 if jump>ans: ans+=1 print(ans)