#include <iostream>
#include <cstdlib>

using namespace std;

int n = 0;
int even[10] = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9};
int edigit = 0;
int odigit = 0;
int sum = 0;
char ID[100001];
int m = 0;
int a[10];
int answer = 0;

int dfs(int depth, int _sum) {
    int count = 0;
    if (depth < edigit) {
        for (int i = 0; i < m; i++) count += dfs(depth+1, _sum+even[a[i]]);
    } else if (depth < edigit + odigit) {
        for (int i = 0; i < m; i++) count += dfs(depth+1, _sum+a[i]);
    } else if ((sum+_sum) % 10 == 0) count = 1;

    return count;
}

int main() {
    cin>>n;
    cin>>ID;
    for (int i = 0; i < n; i++) {
        char str[2] = {ID[i], '\0'};
        if (ID[i] == '*') (n-i) % 2 == 0 ? edigit++: odigit++;
        else (n-i) % 2 == 0 ? sum += even[atoi(str)] : sum += atoi(str);
    }
    sum %= 10;
    cin>>m;
    for (int i = 0; i < m; i++) cin>>a[i];
    cout<<dfs(0, 0)<<endl;
}