mod=10**9+7
io = STDIN
s=io.gets.chomp.split(//).reverse
dp=Array.new(13,0)
dp[0]=1
s.size.times do |i|
  nextdp=Array.new(13,0)
  range=s[i]=="?" ? 0..9 : (s[i].to_i)..(s[i].to_i)
  digit=10**i
  range.each do |k|
    13.times do |j|
      ix=(k*digit+j)%13
      nextdp[ix]+=dp[j]
      nextdp[ix]%=mod
    end
  end
  dp=nextdp
end
p dp[5]
