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