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(7, 1, k) |> IO.puts()
    end
  end

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

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

end
