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