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