let () = let a, b, c, d = Scanf.scanf "%d %d %d %d\n" (fun a b c d -> a, b, c, d) in let d' = d / (c+1) in let b' = d' * c in Printf.printf "%d\n" (if a >= d' && b >= b' then d' else if b >= b' then a else b / c)