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

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

S.length.times do |i|
  c = S[i] == '?' ? -1 : S[i].to_i

  10.times do |j|
    next if c != -1 && c != j

    13.times do |k|
      dp[i + 1][(k * 10 + j) % 13] += dp[i][k]
    end
  end

  13.times { |k| dp[i + 1][k] %= MOD }
end

puts dp[S.length][5]
