'use strict';(function(input){
  
  input=input.trim().split('').map(x=>x-0).reverse();
  
  const N=input.length;
  const M=input.reduce((a,c)=>a+((c===c)?0:1), 0);
  
  const mod = 1e9+7;
  
  const factor=[];
  
  (function(){
    var r=1;
    do{
      factor.push(r);
      r*=10;
      r%=13;
    }while(r!==1);
  })();
  
  const T=factor.length;
  
  const dp=new Array(M+1).fill(0).map(z=>new Array(13).fill(0));
  dp[0][0]=1;
  
  var cur=0,
      m=0;
  
  for(let i=0;i<N;i++){
    let f=factor[i%T],
        n=input[i];
    if(n===n){
      cur=(cur+f*n)%13;
    }else{
      for(let j=0;j<13;j++){
        for(let k=0;k<10;k++){
          let l=(j+f*k)%13;
          dp[m+1][l]=(dp[m+1][l]+dp[m][j])%mod;
        }
      }
      m++;
    }
  }
  const ans=dp[M][(13+5-cur)%13];
  console.log(ans);
})(require('fs').readFileSync('/dev/stdin','utf8'));