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