open System open System.Text.RegularExpressions let pattern = new Regex(@"c.*?w.*?w") let searchCww (str:string) = seq { for i in 0..(str.Length - 3) -> pattern.Match(str, i) } |> Seq.choose (function m when m.Success -> Some m.Length | _ -> None) |> (fun s -> if Seq.isEmpty s then -1 else Seq.min s) Console.ReadLine () |> searchCww |> printfn "%d"