import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val MOD = 1000000007
    val s = readLine()!!.reversed()
    // dp[i][j]: 入力の右からi番目まででj余る
    val dp = Array(s.length + 1) { LongArray(13) }
    dp[0][0] = 1
    var ten = 1
    for (i in s.indices) {
        if (s[i] == '?') {
            for (j in 0..9) {
                val num = (j * ten) % 13
                for (k in 0 until 13) {
                    dp[i + 1][(k + num) % 13] = (dp[i + 1][(k + num) % 13] + dp[i][k]) % MOD
                }
            }
        } else {
            val num = ((s[i] - '0') * ten) % 13
            for (j in 0 until 13) {
                dp[i + 1][(j + num) % 13] = (dp[i + 1][(j + num) % 13] + dp[i][j]) % MOD
            }
        }

        ten = (ten * 10) % 13
    }
    println(dp[s.length][5])
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)
