a,b,c,d = gets.split.map(&:to_i) idealMax = d / c realMax = b / c tempEatNum = [a, realMax, idealMax].min tempEatNum.downto(1){ |value| if value * (c+1) <= d puts value exit end } puts 0