n, x, a, b = $<.map &:to_i p [(x + a - 1) / a, (2**n - x + b - 1) / b].min