A,B,C,D = list(map(int,input().split())) for i in range(1,A+1): if i * C > B or i *C + i> D : a = i -1 break print(a)