let ``No.791 うし数列``() = let s = stdin.ReadLine() if not (s.StartsWith("1") && s.EndsWith("3")) then -1 else s |> Seq.countBy (fun c -> c) |> fun arg -> if (Seq.length arg > 2 || arg |> Seq.tryFind (fun (a,b) -> a = '1') |> fun arg -> arg.IsSome && snd(arg.Value) > 1) then -1 else arg |> Seq.find (fun (k , v) -> '3' = k ) |> fun t -> snd(t) |> stdout.WriteLine () ``No.791 うし数列``()