#include <bits/stdc++.h>
using namespace std;
long long n;
bool pos[0x100], aru[0x100];
bool uniqued;
int main() {
  for (long long i = (long long)('a'); i < (long long)('z' + 1); i++)
    pos[i] = true;
  cin >> n;
  long long res = 0;
  for (long long q = (long long)(0); q < (long long)(n); q++) {
    char c;
    cin >> c;
    long long cnt = 0;
    for (long long i = (long long)('a'); i < (long long)('z' + 1); i++)
      if (pos[i]) cnt++;
    if (cnt == 1) uniqued = true;
    if (c == '.') {
      string s;
      cin >> s;
      for (long long i = (long long)(0); i < (long long)(s.size()); i++)
        pos[s[i]] = false;
    } else if (c == '!') {
      string s;
      cin >> s;
      for (long long i = (long long)(0); i < (long long)(s.size()); i++)
        if (uniqued && pos[s[i]]) {
          res++;
          break;
        }
      for (long long i = (long long)('a'); i < (long long)('z' + 1); i++)
        aru[i] = false;
      for (long long i = (long long)(0); i < (long long)(s.size()); i++) {
        aru[s[i]] = true;
      }
      for (long long i = (long long)('a'); i < (long long)('z' + 1); i++) {
        if (!aru[i]) pos[i] = false;
      }
    } else {
      char cc;
      cin >> cc;
      if (uniqued && !pos[cc])
        res++;
      else
        pos[cc] = false;
    }
  }
  cout << res << endl;
  return 0;
}
