
object Main extends App {
  import scala.io.StdIn._
  val MOD = 1000000007L
  val str = readLine.trim
  var digit = 1
  val count = Array.fill(13){0L}
  count(0) = 1
  for (c <- str.reverse) {
    val temp = Array.fill(13){0L}
    c match {
      case '?' =>
        for (d <- 0 until 10) {
          val diff = d * digit
          for (p <- 0 until 13) {
            temp((p + diff) % 13) += count(p)
          }
        }
      case _ =>
        val diff = c.asDigit * digit
        for (p <- 0 until 13) {
          temp((p + diff) % 13) += count(p)
        }
    }
    for (i <- 0 until 13) {
      count(i) = temp(i) % MOD
    }
    digit = (digit * 10) % 13
  }
  println(count(5))
}