fun main(args: Array<String>) {
    val mod = 1000000007L
    val S = readLine()!!
    var dp = LongArray(13){0L}
    dp[0]++
    
    for (c in S) {
        val tmp = LongArray(13){0L}
        val list = if(c == '?') IntArray(10){it} else intArrayOf(c-'0')

        for (n in list) {
            for ((i,d) in dp.withIndex()) {
                val pos = (10*i + n)%13
                tmp[pos] = (tmp[pos] + d)%mod
            }
        }

        dp = tmp
    }

    println(dp[5])
}