a,b,c,d=map(int,input().split()) s=min(a,b//c) t=d//(c+1) print(min(s,t))