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