a, b, c, d = gets.chomp.split.map(&:to_i) puts [b/c, d/(c+1)].min