defmodule Main do

  def main do
    k = IO.gets("") |> String.trim() |> String.to_integer()
    case rem(k, 2) or rem(k, 5) do
      0 -> IO.puts(-1)
      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
    r = n |> rem(9*k) |> Kernel.*(10)
    search(k, i+1, r)
  end
end
