#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

int allSum, ans;
int n, m, a[12];
string s;
vector<int> pos;

int getCost(int idx, int digit){
  if((n - idx) % 2 == 0){
    digit *= 2;
  }
  if(digit >= 10){
    digit = digit / 10 + digit % 10;
  }

  return digit;
}

void solve(int idx, int sum){
  if(idx == pos.size()){
    if((allSum + sum) % 10 == 0){
      ans++;
    }
    return;
  }

  for(int i = 0; i < m; i++){
    solve(idx + 1, sum + getCost(pos[idx], a[i]));
  }
}

int main(){
  while(cin >> n){
    cin >> s;
    cin >> m;
    for(int i = 0; i < m; i++){
      cin >> a[i];
    }

    allSum = 0;
    pos.clear();

    for(int i = 0; i < n; i++){
      if(s[i] == '*'){
	pos.push_back(i);
      }
      else{
	allSum += getCost(i, s[i] - '0');
      }
    }

    ans = 0;
    solve(0, 0);
    cout << ans << endl;
  }

}