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