program sample
    implicit none
  
    integer(8) :: i,j,m,n,k,a
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) k
    if(mod(k,2)==0)then
        write(*,*)-1
        stop
    end if
    a=7
    m=0
    do i=1,k+1
        if(mod(a,k)==0)then
            write(*,*)i
            stop
        else
            a=mod(a,k)
            a=a*10+7
        end if
    end do
    write(*,*) -1
  
    stop
end program sample
  

