a, b, c, d = map(int, input().split()) l = [] for i in range(a+1): if i + i*c <= d and i*c <= b: l.append(i) print(max(l))