#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int a[20], pos[10];
int n, m, cnt = 0;
int ans = 0, sum = 0;

void dfs(int size, int Sum) {
	if (size == cnt) {
		if ((sum + Sum) % 10 == 0)ans++;
		return;
	}
	rep(i, m) {
		if (pos[size] % 2 == 1)
			dfs(size + 1, Sum + a[i] * 2 % 10 + a[i] * 2 / 10);
		else dfs(size + 1, Sum + a[i]);
	}
}
int main() {
	string id;
	cin >> n >> id >> m;
	rep(i, m)scanf("%d", &a[i]);
	rep(i, n) {
		if (id[i] == '*')pos[cnt++] = n - i - 1;
		else if ((n - i - 1) % 2 == 1)
			sum += (id[i] - '0') * 2 % 10 + (id[i] - '0') * 2 / 10;
		else sum += id[i] - '0';
	}
	dfs(0, 0);
	printf("%d\n", ans);
}