#うまい人の解答見た d = gets.chomp.to_i # jump = 100 # ans = 10 ** 19 def f(x,limt) len = 0 cnt = 0 while x > 0 && cnt < limt len += x x = x/ 2 cnt += 1 #x = x / 2 #jump_count += 1 end return len end ans = d 1.upto(100) do |i| left = 0 right = 10 ** 19 while (left - right) > 1 mid = (left + right) / 2 if d <= f(mid,i) right = mid else left = mid end end if f(right,i) == d && ans > right ans = right end end puts ans