a, b, c, d = map(int, input().split()) e = d // (c + 1) print(e if e <= a and e * c <= b else min(a, b // c))