defmodule Main do

  def main do
    k = IO.gets("") |> String.trim() |> String.to_integer()
    case {rem(k, 2), rem(k, 5)} do
      {0, _} -> IO.puts(-1)
      {_, 0} -> IO.puts(-1)
      _ -> search(k, 1, 10) |> IO.puts()
    end
  end

  defguard ok?(n, k) when rem(n, k) == 1

  def search(k, i, n) when ok?(n, 9*k), do: i
  def search(k, i, n) do
    search(k, i+1, rem(n, 9*k) * 10)
  end
end
