
MOD=10**9+7
s=gets
s.chomp!
s.reverse!
dp=Array.new(s.length+1){Array.new(13,0)};dp[0][0]=1

coef=1
(s.length).times do |i|
  13.times do |j|
    if s[i]=='?'
      10.times do |k|
        dp[i+1][(j+coef*k)%13]=(dp[i+1][(j+coef*k)%13]+dp[i][j])%MOD
      end
    else
      si=s[i].to_i
      dp[i+1][(j+coef*si)%13]=(dp[i+1][(j+coef*si)%13]+dp[i][j])%MOD
    end
  end
  coef=coef*10%13
end

puts dp[s.length][5]