import scala.io.StdIn._
object Main extends App {
  val Mod = 1000000007
  val s = readLine

  def dp(rems: Array[Long], digit: Char): Array[Long] = {
    val ret = new Array[Long](13)
    val is = if (digit == '?') (0 to 9) else Seq((digit - '0').toInt)
    for {
      i <- is
      j <- (0 to 12)
    } {
      ret((j * 10 + i) % 13) += rems(j)
      ret((j * 10 + i) % 13) %= Mod
    }
    ret
  }

  val init = s.head match {
    case '?' => Array.tabulate(13)(i => if (i < 10) 1L else 0L)
    case c => Array.tabulate(13)(i => if (i == c - '0') 1L else 0L)
  }

  val result = s.tail.foldLeft(init){(z, d) => dp(z, d)}
  println(result(5))
}