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

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