program example
	implicit none

	integer(8) :: N,P,i,j,t,wa=0
    character(32) S,u
    
    read(*,*) N,P
   
    read(*,*) S
    
    read(S,*) t
    
    do i=0,t
    	if (mod(i,P)==0) then
        	write(u,*) i
            j=1
            do
            	if (index(trim(adjustl(S(j:))),trim(adjustl(u)))/=0) then
            		wa=wa+1
                    j=j+index(trim(adjustl(S(j:))),trim(adjustl(u)))
				else
                	exit
            	end if
            end do
            j=1
            do
            	if (index(trim(adjustl(S(j:))),"0"//trim(adjustl(u)))/=0) then
            		wa=wa+1
                    j=j+index(trim(adjustl(S(j:))),"0"//trim(adjustl(u)))                
				else
                	exit
            	end if
            end do
            
        end if
    end do

	if(wa/=0) then
		write(*,*) wa
	else
    	write(*,*) "-1"
    end if
end program example