Scanf.scanf "%s" (fun s -> let n = String.length s in let rec loop i = if i = n then i - 1 else if s.[i] = '3' then loop (i + 1) else (-1) in (if s.[0] <> '1' then (-1) else loop 1) |> Printf.printf "%d\n" )