a, b, c, d = map(int, input().split()) ans = 0 for x in range(a + 1): if c * x <= b and x + c * x <= d: ans = x print(ans)