fun main(args: Array<String>) {
    val s = readLine() ?: return
    val mod = 1000000000 + 7
    val n = s.length

    var dp = listOf(1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)

    for (i in 0 until n) {
        val c = s[i]
        val ndp = mutableListOf(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)
        if (c != '?') {
            val num = c.toString().toInt()
            for (m in 0 until 13) {
                ndp[(m * 10 + num) % 13] += dp[m]
            }
        } else {
            for (num in 0 until 10) {
                for (m in 0 until 13) {
                    ndp[(m * 10 + num) % 13] += dp[m]
                }
            }
        }
      
        dp = ndp.map { it % mod }
    }

    println(dp[5])
}