def distance(L, count): res = 0 v = L for i in range(count): res += v v //= 2 return res ans = 10**40 D = int(input()) for bound in range(1, 100): l, r = 0, 10**20 while r - l > 1: m = (r + l)//2 if distance(m, bound) < D: l = m else: r = m if distance(r, bound) == D: ans = min(ans, r) print(ans)