program main
    implicit none
    integer k,now,i,ch
    read(*,*)k
    now=7
    ch=1
    do i=1,k
        if(mod(now,k)==0) then
            write(*,*)i
            ch=0
            exit
        else
            now=mod(10*now+7,k)
        endif
    enddo
    if(ch==1)then
        write(*,*) -1
    endif

end program main