const val mod = 1000000007

fun main(A: Array<String>) {
    val a = LongArray(13) { 0L }
    val b = LongArray(13) { 0L }
    a[0] = 1

    for (c in readLine()!!) {
        val range = if (c == '?') 0..9 else (c - '0')..(c - '0')

        for (j in range)
            for (k in a.indices)
                b[(k * 10 + j) % 13] += a[k] % mod

        System.arraycopy(b, 0, a, 0, 13)
        b.fill(0)
    }
    println(a[5] % mod)
}
