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