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 : print(i-1) break if i == A: print(i)