defmodule Main do def calc("", index) do index - 1 end def calc(s, index) do x = String.first(s) xs = String.slice(s, 1..-1) calc(x, xs, index) end def calc("1", xs, 0) do calc(xs, 1) end def calc(_, _, 0) do -1 end def calc("3", xs, index) do calc(xs, index + 1) end def calc(_, _, _) do -1 end def main do s = IO.gets("") |> String.trim calc(s, 0) |> IO.puts end end