S = gets.chomp
S.reverse!
dp = Array.new(S.size+1).map{Array.new(13,0)}
dp[0][0] = 1
digit = 1
mm = 10**9 + 7
(S.size).times{|i|
    if S[i] != '?'
        c = S[i].to_i
        for j in 0..12 do
            dp[i+1][((c * digit) % 13 + j)% 13] += dp[i][j]
            dp[i+1][((c * digit) % 13 + j)% 13] %= mm
        end
    else
        for c in 0..9 do
            for j in 0..12 do
                dp[i+1][((c * digit) % 13 + j)% 13] += dp[i][j]
                dp[i+1][((c * digit) % 13 + j)% 13] %= mm
            end
        end
    end
    digit *= 10
    digit %= 13
}
puts dp[S.size][5]
