A,B,C,D = map(int,input().split()) ans = 0 for veg in range(1,A+1): meat = veg*C if meat > B or meat+veg > D: break else: ans = veg print(ans)