n = gets.chomp.split("").reverse
dp = Array.new(13,0)
dp[0]=1
nextdp = Array.new(13,0)
n.each_with_index{|ni, keta|
    nextdp.fill(0)
if ni == "?" then
    10.times{|n|
        mod = (n* (10**keta))%13
        13.times{|t|
            nextdp[(mod+t)%13] += dp[t]
        }
    }
else
    mod = (ni.to_i* (10**keta))%13
    13.times{|t|
        nextdp[(mod+t)%13] += dp[t]
    }
end
nextdp.each_with_index{|item, t|
    dp[t] = item % 1000000007
}
}
puts dp[5]
