defmodule Main do def main do IO.read(:line) |> String.trim() |> solve |> IO.puts() end defp solve(n) do n |> String.slice(1..-1) |> (fn o -> s = o |> String.length() t = o |> String.to_charlist() |> Enum.count(&(&1 == ?3)) cond do n |> String.first() != "1" || s != t || t == 0 -> -1 true -> s end end).() end end