a,b,c,d = map(int,input().split()) print(a if a*c <= b and a*(c+1) <=d else d//(c+1) if a*c <= b else b//c)