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