A,B,C,D=[int(i) for i in input().split()] lim1 = B//C lim2 = D//(C+1) group = min(lim1,lim2,A) print(group)