a, b, c, d = read_line.split.map(&.to_i) if a == 0 a = 1 c = 9999 end if b == 0 b = 1 d = 9999 end puts [c // a, d // b].min