MOD = 10**9+7
s = gets.chomp
len = s.length
num = Array.new(2).map{Array.new(13,0)}

num[0][0] = 1

for i in 0..len-1
  #13.times do |j|
  #  num[(i+1)%2][j] = 0
  #end
  if s[i] == "?"
    10.times do |j|
      13.times do |k|
        num[(i+1)%2][(k*10+j)%13] += num[i%2][k]
      end
    end
  else
    j = s[i].to_i
    13.times do |k|
      num[(i+1)%2][(k*10+j)%13] += num[i%2][k]
    end
  end
  13.times do |k|
    num[(i+1)%2][k] %= MOD
  end
end

puts num[len%2][5]