A,B,C,D = map(int,input().split()) max_a = B // C if B // C <= A else A real = max_a while real != 0: if real + real * C <= D: break real-=1 print(real)