MOD = 10 ** 9 + 7

s = gets.chomp.chars
n = s.size
m = 13
dp = Array.new(n) { Hash.new(0) }

n.times do |i|
  if i == 0
    if s[i] != "?"
      dp[i][s[i].to_i] = 1
    else
      10.times {|c| dp[i][c] = 1 }
    end
  else
    if s[i] != "?"
      c = s[i].to_i
      dp[i - 1].each do |k, v|
        l = (10 * k + c) % m
        dp[i][l] += v
        if dp[i][l] >= MOD
          dp[i][l] -= MOD
        end
      end
    else
      dp[i - 1].each do |k, v|
        10.times do |c|
          l = (10 * k + c) % m
          dp[i][l] += v
          if dp[i][l] >= MOD
            dp[i][l] -= MOD
          end
        end
      end
    end
  end
end
puts dp[-1][5]