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