let rec check2 a lst = match lst with | [] -> 0 | head :: tail -> if head <> a then 1 + check2 a tail else check2 a tail let rec check a b lst = if a > b then 0 else check2 a lst + check (a+1) b lst let () = let a, b, c, d = Scanf.scanf "%d %d %d %d\n" (fun a b c d -> a, b, c, d) in let rec make_lst a b = if a = b then [a] else a :: make_lst (a+1) b in let lst = make_lst c d in Printf.printf "%d\n" (check a b lst)