#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

#define rep(i,a,b) for(int i=(a); i<(b); i++)

// i番目(0-index)にnが来た
int dig(int i, int n){
  if(i%2 == 1) n*=2;
  if(n>9) n = n/10 + n%10;
  return n;
}

int n,m;
string id;
int a[10];
unsigned int dp[100000][10];

int main(){
  cin >> n >> id >> m;
  rep(i,0,m) cin >> a[i];
  
  reverse(id.begin(), id.end());

  memset(dp,0,sizeof(dp));
  dp[0][0] = 1;
  rep(i,0,n){
    rep(j,0,10){
      if(id[i] != '*'){
        dp[i+1][(j+dig(i,id[i]-'0'))%10] += dp[i][j];
      } else {
        rep(k,0,m){
          dp[i+1][(j+dig(i,a[k]))%10] += dp[i][j];
        }
      }
    }
  }

  cout << dp[n][0] << endl;
  return 0;
}