open System.Text.RegularExpressions let ``No.345 最小チワワ問題``() = let s = stdin.ReadLine() let regCWW = Regex("(c[abdefghijklmnopqrstuvxyz]*w[abcdefghijklmnopqrstuvxyz]*w)") let regCWW = Regex("(c[abdefghijklmnopqrstuvxyz]*w[abdefghijklmnopqrstuvxyz]*w)") match regCWW.IsMatch s with | false -> -1 |> stdout.WriteLine | true -> seq { for g in regCWW.Matches(s).[0].Groups do yield g.Value.Length } |> Seq.minBy (fun s -> s) |> stdout.WriteLine ``No.345 最小チワワ問題``()