MOD = 10 ** 9 + 7
S = gets.chomp
dp = Array.new(S.size + 1) { Array.new(13,0) }

dp[0][0] = 1

S.size.times do |i|
  c = -1
  c = S[i].to_i if S[i] != '?'

  10.times do |j|
    next unless c == -1 || c == j
    13.times do |k|
      dp[i + 1][(k * 10 + j) % 13] += dp[i][k]
    end
  end
  13.times do |k|
    dp[i + 1][k] %= MOD
  end
end
puts dp[S.size][5]
