#include <bits/stdc++.h>
using namespace std;

vector<int> av;
int c=0,dc=0,res=0;

void solve(int count,int sm){
    if(count == c){
        if(sm%10 == 0) res++;
        return;
    }

    for(auto x:av){
        if(count < dc){
            int t=2*x;
            if(t>=10){
                string s=to_string(t);
                t = s[0]-'0'+s[1]-'0';
            }
            solve(count+1,sm+t);
        }
        else solve(count+1,sm+x);
    }
}


int main(){
    int n,m,sum=0;
    string s;
    cin>>n>>s>>m;
    av.resize(m);
    for(auto& x:av) cin >> x;

    for(int i=0;i<n;i++){
        if(s[i] == '*'){
            c++;
            if((n-1-i) & 1) dc++;
        }else{
            int t=s[i]-'0';
            if((n-1-i) & 1){
                t*=2;
                if(t>=10){
                    string ss=to_string(t);
                    t = ss[1]-'0'+ss[0]-'0';
                }
            }
            sum += t;
        }
    }

    solve(0,sum);

    cout << res << endl;
}