MOD = 1000000007

S = gets.chomp
ssize = S.size
ord_0 = '0'.ord

R0010 = 0...10

dp = Array.new(ssize+1).map{ Array.new(13, 0) }
dp[0][0] = 1

1.upto(ssize) do |i|
  s = S[i-1]
  numbers = s == '?' ? R0010 : [s.ord - ord_0]
  numbers.each do |x|
    13.times { |z|
      dp[i][(z * 10 + x) % 13] += dp[i-1][z]
    }
  end
  (0...13).each { |z| dp[i][z] %= MOD }
end

p dp[ssize][5]
