D = int(input()) # むむむ、二分探索と思ったらDにぴったり止まる必要ある # つまり行き過ぎてはダメなので二分探索ではダメか # その数が辿り着く数列を考える必要あるか def max_distance(num): dist = 0 reached = [] while num >= 1: dist += num num //= 2 reached.append(dist) return dist, reached OK = D+1 NG = 0 while OK-NG>1: mid = (OK+NG)//2 if max_distance(mid)[0] >= D: OK = mid else: NG = mid candidate = OK while True: if D in max_distance(candidate)[1]: print(candidate) break else: candidate += 1