program main
    implicit none
    integer(kind=16) :: k,ans,i,j,tmp
    read*,k

    keta:do i=1,10000
        tmp = 7
        do j = 1,i
            tmp = tmp + 7*10**j
        end do
        if (mod(tmp,k) == 0) then
            ans = i + 1
            print*,ans
            stop
        end if
    end do keta
    print*,-1
end program main