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