s = gets.chomp
div = 1000000007
min = s.gsub("?","0").to_i
max = s.gsub("?","9").to_i

xmin = ((min-5).to_f / 13.0).ceil
xmax = ((max-5).to_f / 13.0).ceil

def check(str,num)
  puts "error #{str} #{num}" if str.size != num.size
  if /#{str}/ =~ num
    return true
  else
    return false
  end
end
count = 0
scheck = s.gsub("?",".").gsub(/\A\.+/,"")
ssize  = scheck.size
xmin.upto(xmax) do |x|
  checknums = (13*x+5).to_s
  checknum = checknums[-ssize,ssize]
  if check(scheck,checknum)
    count += 1
  end
end

puts count%div