d = int(input()) def cal(a): cnt = 0 for i in range(k): cnt += a a//=2 return cnt ans = d for k in range(65): ng = 0 ok = d while ok - ng > 1: mid = (ok + ng)//2 t=cal(mid) if t >= d: ok = mid else: ng = mid if t == d: ans = min(ans,mid) print(ans)