program ABC174C
    implicit none
    integer(8)::K,L,i,mod0,mod_ans,flg=0,larger=0
    read*,K
    if(mod(K,2)==0.or.mod(K,5)==0)then
        print'(i0)',-1
    else
        if(mod(K,7)==0)then
            L=9*K/7
        else
            L=9*K
        end if

        do i=0,9000000
            if(10**i>=L.and.larger==0)larger=1
            if(i==0)then
                mod_ans=mod(1,L)
            else
                mod_ans=mod(mod0*10,L)
            end if
            if(larger==1.and.mod_ans==1)then
                flg=1
                exit
            end if
            mod0=mod_ans
        end do
        if(flg==1)print'(i0)',i
        if(flg==0)print'(i0)',-1
    end if
end program ABC174C