def solve(x, n): res = 0 for _ in range(n): res += x x //= 2 return res D = int(input()) INF = 10**18+1 ans = INF for i in range(1, 61): ng, ok = 0, INF while ok-ng > 1: m = (ng+ok)//2 if solve(m, i) >= D: ok = m else: ng = m if solve(ok, i) == D: ans = min(ans, ok) print(ans)