require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
s = gets.chomp.split(//)

dp = Array.new(s.size+1){Array.new(13, 0)}
dp[0][0] = 1
s.size.times do |i|
  13.times do |j|
    if s[i] != '?'
      dp[i+1][(j*10 + s[i].to_i)%13] += dp[i][j]
      dp[i+1][(j*10 + s[i].to_i)%13] %= MOD
    else
      10.times do |k|
        dp[i+1][(j*10 + k)%13] += dp[i][j]
        dp[i+1][(j*10 + k)%13] %= MOD
      end
    end
  end
#  p "----"; dp.each{|line| p line}
end

puts dp[s.size][5]