MOD = 10**9 + 7

s = gets.chomp.split('')

ss = []
s.each{ |x|
	if x == '?' then
		ss << nil
	else
		ss << x.to_i
	end
}

dp = Array.new(13, 0)
dp[0] = 1

dp_next = []

(0 ... ss.size).each{ |i|
	dp_next = Array.new(13, 0)

	13.times { |j|
		if ss[i] == nil then
			10.times{ |k|
				dp_next[(j * 10 + k) % 13] += dp[j]
			}
		else
			dp_next[(j * 10 + ss[i]) % 13] += dp[j]
		end
	}
	
	13.times { |j|
		if dp_next[j] > MOD then
			dp_next[j] = dp_next[j] % MOD
		end
	}

	dp = dp_next
}

puts dp[5] % MOD
