D = int(input()) ok = pow(10,20) ng = 0 def check(x,loop): ret = x for i in range(loop): x = x//2 ret += x return ret #print(check(5,1)) ans = float("inf") MAX = 70 for i in range(MAX): ok = pow(10,20) ng = 0 while abs(ok-ng) > 1: #and cnt < 100: mid = (ok+ng)//2 #print(ok,mid,ng) if check(mid,i) >= D: ok = mid else: ng = mid #print(ok,check(ok,i)) if check(ok,i) == D: ans = min(ans,ok) print(ans)