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

l = S.length
dp = Array.new(l + 1){Array.new(13, 0)}
dp[0][0] = 1
S.chars.each_with_index do |c, i|
  (c == '?' ? [*0 .. 9] : [c.to_i]).each do |j|
    (0 ... 13).each{|k| dp[i + 1][(10*k + j) % 13] = (dp[i + 1][(10*k + j) % 13] + dp[i][k]) % MOD}
  end
end
puts dp[l][5]