character(10**5) S
integer,dimension(:,:)::DP(0:12,0:1)
integer keta(6)
integer SL
character A
read*,S
SL=len_trim(S)
DP=0
keta=[1,10,9,12,3,4]
DP(0,0)=1

do i=1,SL
  A=S(SL-i+1:SL-i+1)
  if(A=="?")then
  do j=0,9
    do k=0,12
      jj=mod(j*Keta( mod(i-1,6) +1 )+k,13)
      DP(jj,1)=mod(DP(jj,1)+DP(k,0),10**9+7)
    end do
  end do
  else
    jj=(ichar(A)-48)*Keta( mod(i-1,6) +1 )
    do j=0,12
      DP(mod(jj+j,13),1)=DP(j,0)
    end do
  endif
  DP(:,0)=DP(:,1)
  DP(:,1)=0
end do
print"(i0)",DP(5,0)
end