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