program repsept
  implicit none
  integer :: k, i, m = 0
  read(*,*) k
  do i = 1, 2 * k
    m = mod(10 * m + 7, k)
    if (m == 0) then
      write(*,'(i0)') i
      stop
    end if
  end do
  write(*,'(i0)') -1
end program repsept