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