# coding: utf-8 # Your code here! D=int(input()) MAX_BOUND=64 def calc_distance(init_power): rev=0 while init_power: rev+=init_power init_power//=2 return rev ans=D for k in range(MAX_BOUND): high=2**(k+1)-1 low=2**k #error判定 high_distance=calc_distance(high) low_distance=calc_distance(low) if low_distance<=D<=high_distance: pass else: continue while high-low>1: middle=(high+low)//2 distance=calc_distance(middle) if distance>=D: high=middle else: low=middle ans=min(ans,middle) print(ans)