#include <bits/stdc++.h>
using namespace std;
const int ALF = 333;
int N;
string s;
bool was[ALF];
bitset<ALF> ba, bb;
bool bad(string &t) {
  for (int i = 0; i < (int)s.size(); i++) {
    if (s[i] == '*') {
      if (was[t[i]]) return true;
    } else {
      if (s[i] != t[i]) return true;
    }
  }
  return false;
}
void handle(string &t) {
  ba.reset();
  for (int i = 0; i < (int)s.size(); i++) {
    if (s[i] == '*') ba[t[i]] = 1;
  }
  bb &= ba;
}
void solve() {
  cin >> s >> s;
  for (char x = 'a'; x <= 'z'; x++) bb[x] = 1;
  for (auto x : s) was[x] = 1;
  cin >> N;
  string t;
  bool has_one = false;
  for (int i = 0; i < N; i++) {
    cin >> t;
    if (bad(t)) continue;
    handle(t);
    has_one = 1;
  }
  cout << (has_one ? bb.count() : 0);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
