#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
template <class T>
inline T biton(T n, T pos) {
  return n | ((T)1 << pos);
}
template <class T>
inline T bitoff(T n, T pos) {
  return n & ~((T)1 << pos);
}
template <class T>
inline T ison(T n, T pos) {
  return (bool)(n & ((T)1 << pos));
}
template <class T>
inline T gcd(T a, T b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
template <typename T>
string NumberToString(T Number) {
  ostringstream second;
  second << Number;
  return second.str();
}
inline int nxt() {
  int aaa;
  scanf("%d", &aaa);
  return aaa;
}
inline long long int lxt() {
  long long int aaa;
  scanf("%lld", &aaa);
  return aaa;
}
inline double dxt() {
  double aaa;
  scanf("%lf", &aaa);
  return aaa;
}
template <class T>
inline T bigmod(T p, T e, T m) {
  T ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % m;
    p = (p * p) % m;
  }
  return (T)ret;
}
int ar[200010];
int mark[1005];
int bad[1005];
string t[1006];
int ache[1005][1005];
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++)
    if (s[i] != '*') mark[s[i]] = 1;
  int q;
  cin >> q;
  vector<int> v;
  for (int j = 0; j < q; j++) {
    cin >> t[j];
    bool f = 0;
    for (int i = 0; i < t[j].size(); i++) {
      if (s[i] != '*') {
        if (t[j][i] != s[i]) {
          bad[j] = 1;
          break;
        }
      }
    }
    if (!bad[j]) {
      for (int i = 0; i < t[j].size(); i++) {
        if (s[i] == '*' && mark[t[j][i]]) {
          bad[j] = 1;
          break;
        }
      }
    }
    if (!bad[j]) v.push_back(j);
  }
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j < t[v[i]].size(); j++) {
      if (s[j] == '*') {
        ache[i][t[v[i]][j] - 'a'] = 1;
      }
    }
  }
  memset(mark, 0, sizeof(mark));
  int ans = 0;
  for (int i = 0; i < v.size(); i++) {
    string sp = t[v[i]];
    int cnt = 0;
    memset(mark, 0, sizeof(mark));
    for (int j = 0; j < n; j++) {
      if (s[j] == '*') {
        int id = sp[j] - 'a', flag = 0;
        for (int k = 0; k < v.size(); k++) {
          if (!ache[k][id]) {
            flag = 1;
          }
        }
        if (mark[id]) continue;
        mark[id] = 1;
        if (!flag) cnt++;
      }
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}
