D = gets.to_i def f(x) len = 0 while x > 0 && len < D len += x x /= 2 end len end ng = 0 ok = 10 ** 18 while (ok - ng).abs >= 2 x = (ok + ng) / 2 if D <= f(x) ok = x else ng = x end end if f(ok) == D puts ok elsif f(ok + 1) == D puts ok + 1 else puts D end