S = gets.chomp
MOD = 10**9 + 7

n = 13
# dp[k] -> 13で割った余りがkのパターン数
dp = Array.new(n, 0)
dp[0] = 1

S.chars.each do |char|
  next_dp = Array.new(n, 0)

  if char == '?'
    10.times do |num|
      n.times do |k|
        rem = (k * 10 + num) % n
        next_dp[rem] += dp[k]
        next_dp[rem] %= MOD
      end
    end
  else
    num = char.to_i
    n.times do |k|
      rem = (k * 10 + num) % n
      next_dp[rem] += dp[k]
      next_dp[rem] %= MOD
    end
  end

  dp = next_dp
end

puts dp[5]