program baisuu_search
    integer(8) :: K, i
    integer(8) :: c = 0
    logical :: f = .false.

    read *, K
    do i = 7 , K, i*10+7
        c = c + 1
        if(mod(i, K) .eq. 0)then
            f = .true.
        end if
        if(f .eqv. .true.)exit
    end do
    if(f .eqv. .true.)then
        print *, c
    else
        print *, '-1'
    end if
end program