
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|
  if s[i]=='?'
    13.times do |j|
      10.times do |k|
        ind=(j+coef*k)%13
        temp=dp[i+1][ind]+dp[i][j]
        dp[i+1][ind] = temp>=MOD ? temp-MOD : temp
      end
    end
  else
    si=s[i].to_i
    13.times do |j|
      ind=(j+coef*si)%13
      temp=dp[i+1][ind]+dp[i][j]
      dp[i+1][ind] = temp>=MOD ? temp-MOD : temp
    end
  end
  coef=coef*10%13
end

puts dp[s.length][5]