Scanf.scanf "%d %d %d %d" (fun a b c d -> let rec loop_i i acc = let rec loop_j j acc = if j > d then acc else let acc = if i <> j then acc + 1 else acc in loop_j (j + 1) acc in if i > b then acc else loop_i (i + 1) (loop_j c acc) in loop_i a 0 |> Printf.printf "%d\n" )