//package practice.task1

import scala.collection.mutable

object Main extends App {
  val S: String = io.StdIn.readLine()
  val MOD = 1000000007
  var dp: Seq[mutable.HashMap[Int, Long]] =
    (0 to S.length).map(
      _ =>
        mutable.HashMap[Int, Long](
          (0, 0),
          (1, 0),
          (2, 0),
          (3, 0),
          (4, 0),
          (5, 0),
          (6, 0),
          (7, 0),
          (8, 0),
          (9, 0),
          (10, 0),
          (11, 0),
          (12, 0)
      )
    )
  dp.head(0) = 1

  var m: Int = 1
  for (i <- 0 until S.length) {
    val C: Char = S(S.length - i - 1)
    if (C != '?')
      for (k <- 0 to 12) {
        dp(i + 1)((k + m * C.toString.toInt % 13) % 13) = dp(i)(k)
      } else
      for (j <- 0 to 9) {
        for (k <- 0 to 12) {
          dp(i + 1)((k + m * j % 13) % 13) = (dp(i + 1)((k + m * j % 13) % 13) + dp(i)(k)) % MOD
        }
      }
    m = m * 10 % 13
  }

  println(dp(S.length)(5))
}
