s = gets.chomp

n = Array.new(s.length)
n[0] = 1
for i in 1...s.length
    n[i] = (n[i-1] * 10) % 13
end

# dp[i][j] : 数
#   i : 桁
#   j : あまり
dp = Array.new(s.length+1).map{Array.new(13, 0)}

dp[0][0] = 1

s.reverse!
s.chars.each_with_index do |c, i|
    if c == "?"
        j = 0
        while j < 13
            k = 0
            while k < 10
                x = (j + k * n[i]) % 13
                dp[i+1][x] = (dp[i+1][x] + dp[i][j]) % 1000000007
                k += 1
            end
            j += 1
        end
    else
        j = 0
        while j < 13
            x = (j + c.to_i * n[i]) % 13
            dp[i+1][x] = dp[i][j]
            j += 1
        end
    end
end

puts dp[s.length][5]
