s = gets.chomp.reverse
n = s.size
mod = 10 ** 9 + 7

t = Array.new(n, 1)
1.upto(n-1) {|i| t[i] = t[i-1] * 10 % 13}

dp = Array.new(13, 0)
(c = s.slice!(0)) == ?? ? dp.fill(1, 0..9) : dp[c.to_i] = 1

s.each_char.with_index(1) do |c, i|
    if c == ??
        x = Array.new(13, 0)
        10.times do |j|
            z = t[i] * j % 13
            13.times {|k| x[k] += dp[k - z]}
        end
        dp = x.map! {|e| e % mod}
    else
        z = t[i] * c.to_i % 13
        dp.rotate!(-z)
    end
end

puts dp[5]