#include<cstdio>
#include<cstring>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int n,m,a[10],len;
char ID[100001];

int f(int a){ a*=2; return a<10?a:a/10+a%10; }

int dp[100000][10];
int dfs(int i,int sum){
	if(i==len) return sum%10==0?1:0;

	if(dp[i][sum%10]!=-1) return dp[i][sum%10];

	int res=0;
	if(ID[i]=='*'){
		if(i%2==0) rep(j,m) res+=dfs(i+1,sum+a[j]);
		else       rep(j,m) res+=dfs(i+1,sum+f(a[j]));
	}
	else{
		if(i%2==0) res=dfs(i+1,sum+ID[i]-'0');
		else       res=dfs(i+1,sum+f(ID[i]-'0'));
	}
	return dp[i][sum%10]=res;
}

int main(){
	scanf("%d%s%d",&n,ID,&m);
	rep(i,m) scanf("%d",a+i);

	len=strlen(ID);
	reverse(ID,ID+len);

	memset(dp,-1,sizeof dp);
	printf("%d\n",dfs(0,0));

	return 0;
}