import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Queue, PriorityQueue}

object Main extends App {
  def repeatSquares(x: Long, n: Int, mod: Int): Long = {
    if(n == 0)
      1
    else if(n % 2 == 0)
      repeatSquares(x*x % mod, n/2, mod)
    else
      (x * repeatSquares(x*x % mod, n/2, mod)) % mod
  }


  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  
  val _S = in.next()

  //
  val MOD = 1e9.toInt + 7

  val N = _S.length
  val S = "0" + _S.reverse
  //val a = new Array[Int](N)


  val dp = Array.ofDim[Long](N+1, 13)
  dp(0)(0) = 1

  for (i <- 1 to N) {
    val _now = S(i)
    val base = repeatSquares(10, i-1, MOD)

    if (_now == '?') {
      for (now <- 0 to 9) {
        for (k <- 0 until 13) {
          if (dp(i-1)(k) > 0) {
            val hoge = ((now * base + k) % 13).toInt
            dp(i)(hoge) += dp(i-1)(k)
            dp(i)(hoge) %= MOD
          } 
        }
      }
    }
    else {
      val now = _now.toInt - '0'.toInt

      for (k <- 0 until 13) {
        if (dp(i-1)(k) > 0) {
          val hoge = ((now * base + k) % 13).toInt
          dp(i)(hoge) += dp(i-1)(k)
          dp(i)(hoge) %= MOD
        }
      }
    }
  }

  //dp.foreach(a => println(a.deep))
  println(dp(N)(5))
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
