fun main(args: Array<String>) {
	val MOD : Long = java.lang.Math.pow(10.0, 9.0).toLong() + 7

	var s = readLine()!!.trim().toCharArray().map{ x -> x.toString() }

	var dp = Array(13) { 0L }
	dp[0] = 1L

	for (i in (0 .. (s.size - 1) )) {
		var dp_next = Array(13) { 0L }
	
		if (s[i] == "?") {
			for (j in 0..12){
				for (k in 0..9){
					dp_next[(j * 10 + k) % 13] += dp[j]
				}
			}
		} else {
			for (j in 0..12){
				dp_next[(j * 10 + s[i].toInt()) % 13] += dp[j]
			}
		}

		for (j in 0..12){
			if (dp_next[j] > MOD) {
				dp_next[j] = dp_next[j] % MOD
			}
		}
		
		dp = dp_next
	}

	println(dp[5] % MOD)
}