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