fun main(args: Array<String>) {
    val mod = 1000000007

    val s = readInputLine().toCharArray()
    
    val dp = Array(s.size, {IntArray(13)})
    
    if (s[0] == '?') {
        for (i in 0..9) {
            dp[0][i] = 1
        }
    } else {
        dp[0][(s[0] - '0').toInt()] = 1
    }

    for (i in 1 until s.size) {
        val num = if (s[i] == '?') -1 else (s[i] - '0').toInt()

        if (num != -1) {
            for (j in 0 until 13) {
                dp[i][(j * 10 + num) % 13] = dp[i - 1][j]
            }
        } else {
            for (k in 0..9) {
                for (j in 0 until 13) {
                    dp[i][(j * 10 + k) % 13] += dp[i - 1][j]
                    dp[i][(j * 10 + k) % 13] %= mod
                }
            }
        }
    }
    
    println(dp[s.size - 1][5])
}

fun readInputLine(): String {
    return readLine()!!
}
