a,b,c,d=map(int,input().split())
x=0;y=0
while 0<a and c<=b and y+c+1<=d:
    a-=1;b-=c;x+=1;y+=1+c
print(x)