A,B,C,D = list(map(int,input().split())) res = 0 for i in range(A+1): if i*C <= B and i+B <= D: res = max(res,i) print(res)