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