fun main(args: Array<String>){
    val S = next()
    val N = 13
    val MOD = 1000000007L
    var dp = LongArray(13)
    dp[0] = 1
    for (l in 0 until S.length) {
        val nextDP = LongArray(13)
        val c = if (S[l] == '?') -1 else S[l] - '0'
        for (n in 0 .. 9) {
            if (c != -1 && c != n) continue
            for (j in 0 until N) {
                nextDP[((j * 10) + n) % N] += dp[j]
                nextDP[((j * 10) + n) % N] %= MOD
            }
        }
        dp = nextDP
    }
    println(dp[5])
}
fun next() = readLine()!!