fun main(args: Array<String>){
    val MOD = 1000000007L
    val dp = Array<LongArray>(100005) { LongArray(13) }
    val s = next().toCharArray()
    var n = s.count()
    dp[0][0] = 1
    for (i in 0 until n) {
        val c = if (s[i] == '?') -1 else s[i] - '0'
        for (j in 0 until 10) {
            if (c != -1 && c != j) continue
            for (ki in 0 until 13) {
                dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki]
            }
        }
        for (j in 0 until 13) dp[i + 1][j] %= MOD
    }
    val res = dp[n][5]
    println(res)
}
fun next() = readLine()!!
