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