open System let solve (n: string) = let f = n.Substring(0, 1) let e = n.Substring(1) let ea = e.ToCharArray() if f = "1" && (ea |> Array.forall((=) '3')) then ea |> Array.length else -1 let N = Console.ReadLine() solve N |> Console.WriteLine