#include <bits/stdc++.h>
using namespace std;
int n, Max, res, alpha, cntt;
int cnt[30], num, wrong;
bool dd[30], dd1[30];
string s, ans;
char c;
bool ok = false;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> c;
    cin >> s;
    if (ok) {
      if (((c == '?' || c == '!') && i != n)) {
        res++;
        continue;
      }
    }
    int len = s.size();
    for (int j = 0; j <= 25; j++) dd[j] = false;
    if (c == '!') {
      if (len == 1) {
        ok = true;
        ans = s;
        continue;
      }
      for (int j = 0; j < len; j++) {
        int ch = s[j] - 'a';
        if (!dd[ch]) {
          if (alpha == 26) {
            ans = s[j];
          }
          dd[ch] = true;
          if (cnt[ch] == -1) continue;
          cnt[ch]++;
          if (cnt[ch] > Max) {
            Max = cnt[ch];
            num = 1;
          } else if (cnt[ch] == Max)
            num++;
        }
      }
    } else if (c == '.') {
      for (int j = 0; j < len; j++) {
        int ch = s[j] - 'a';
        if (cnt[ch] == Max) {
          num--;
        }
        cnt[ch] = -1;
      }
    } else {
      cnt[s[0] - 'a'] = -1;
    }
    wrong = 0;
    for (int j = 0; j <= 25; j++) wrong += (cnt[j] == -1);
    if ((num == 1 && ok == false) || (wrong == 25 && ok == false)) {
      ok = true;
    }
  }
  cout << res;
  return 0;
}
