(define (main args) (let* ([n (read)] [x (read)] [a (read)] [b (read)]) (print (min (quotient (+ x a -1) a) (quotient (+ (- (expt 2 (- n 1)) x) b -1) b)))) 0)