#include <iostream>
#include <vector>
using namespace std;
int search(vector<int>& v,vector<int>& w,vector<vector<int> >& x,int id)
{
  if(id == v.size()) return x[id][0];
  if(v[id] != -1){
    int num = v[id];
    if(id % 2 != 0) num *= 2; 
    if(num > 9) num = (num/10) + (num%10);
    for(int i=0; i<10; i++){
      x[id+1][(i+num)%10] += x[id][i];
    }
    return search(v,w,x,id+1);
  }
  for(int i=0; i<w.size(); i++){
    int num = w[i];
    if(id % 2 != 0) num *= 2; 
    if(num > 9) num = (num/10) + (num%10);
    for(int j=0; j<10; j++){
      x[id+1][(j+num)%10] += x[id][j];
    }
  }
  return search(v,w,x,id+1);
}
int main()
{
  int n;
  cin >> n;
  string str;
  cin >> str;
  vector<int> v(n);
  for(int i=0; i<n; i++){
    char c = str[i];
    if(c == '*') v[n-1-i] = -1;
    else v[n-1-i] = c - '0';
  }
  int m;
  cin >> m;
  vector<int> w(m);
  for(int i=0; i<m; i++){
    cin >> w[i];
  }
  vector<vector<int> > x(n+1,vector<int>(10,0));
  x[0][0] = 1;
  int ret = search(v,w,x,0);
  cout << ret << endl;
  return 0;
}