fun main(args: Array<String>) {
    val s = readLine()!!
    val dp = Array(s.length+1) {Array(13) {0L} }
    val mod = 1000000007L
    dp[0][0] = 1L
    for (i in 0 until s.length) {
        for (j in 0 until 13) {
            if (s[i] == '?') {
                for(k in 0..9) {
                    dp[i+1][(j*10 + k) % 13] += dp[i][j]%mod
                }
            } else {
                dp[i+1][(j*10 + (s[i] - '0')) % 13] += dp[i][j]%mod
            }
        }
    }
    println(dp[s.length][5]%mod)
}