n = gets.to_i
s = gets.chomp
gets
candidates = gets.split.map(&:to_i)
dp = [1] + [0] * 9
(0..s.size-1).each do |i|
    new_dp = [0] * 10
    (s[i] == ?* ? candidates : [s[i].to_i]).each do |c|
        if (s.size - i).even?
            c = (c * 2).to_s.split("").map(&:to_i).inject(:+)
        end
        (0..9).each do |j|
            new_dp[(j + c) % 10] += dp[j]
        end
    end
    dp = new_dp
end
p dp[0]
