#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
using namespace std;
int N,M;
string S;
int A[11];
vector<int> D;
int calc(char num){
  int n = (int)(num-'0');
  n*=2;
  return n/10+n%10;
}
int calc(int num){
  int n = num;
  n*=2;
  return n/10+n%10;
}
int solve(int no,int sum){
  if(no==(int)D.size()){
    //    printf("%d\n",sum);
    if(!(sum%10)) return 1;
    return 0;
  }
  int ret=0;
  for(int i=0;i<M;i++){
    ret+= solve(no+1,sum+( ((D[no])%2)?A[i]:calc(A[i])) );
  }
  return ret;
}
int main(){
  cin >> N;
  cin >> S;
  cin >> M;
  for(int i=0;i<M;i++)
    cin >> A[i];
  for(int i=0;i<N;i++)
    if(S[i]=='*') D.push_back(N-i);
  int sum=0;
  for(int i=N-1,j=1;i>-1;i--,j++){
    if(S[i]=='*') continue;
    if(!(j%2)) sum+=calc(S[i]);
    else sum+=(int)(S[i]-'0');
  }
  //  printf("%d\n",sum);
  printf("%d\n",solve(0,sum));
}