a,b,c,d=map(int,input().split()) for i in range(a,-1,-1): if i*c<= b and (c+1)*i<=d: print(i) exit()