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

dp = Array.new(S.size + 1) { Array.new(13, 0) }
base = 1

S.chars.reverse_each.with_index do |s, idx|
  n = s.to_i

  if idx == 0
    if s == '?'
      10.times do |i|
        dp[1][i] = 1
      end
    else
      dp[1][n] = 1
    end
  else
    if s == '?'
      13.times do |i|
        10.times do |j|
          k = (i + (j * base) % 13) % 13
          dp[idx + 1][k] = (dp[idx + 1][k] + dp[idx][i]) % MOD
        end
      end
    else
      13.times do |i|
        j = (i + (n * base) % 13) % 13 
        dp[idx + 1][j] = (dp[idx + 1][j] + dp[idx][i]) % MOD
      end
    end
  end

  base = (base * 10) % 13 
end

puts dp[S.size][5]
