#include <bits/stdc++.h>
using namespace std;
int aa[30][2], flag;
string op, s;
char c;
void _slove(int mx) {
  for (int i = 0; i < 26; i++)
    if (mx == aa[i][0]) {
      c = 'a' + i;
      break;
    }
}
void slove(int &mx, int &k) {
  mx = 0;
  k = 0;
  for (int i = 0; i < 26; i++) {
    if (aa[i][0] > mx) {
      mx = aa[i][0];
      k = 1;
    } else if (mx == aa[i][0])
      k++;
  }
}
int main() {
  int n, m, mx, rs, a, k, count;
  cin >> n;
  flag = count = m = k = rs = mx = a = 0;
  for (int i = 0; i < n - 1; i++) {
    cin >> op >> s;
    m = s.length();
    if (flag) {
      if (op[0] == '!' || op[0] == '?') rs++;
    } else {
      if (op[0] == '?' || op[0] == '.') {
        for (int j = 0; j < m; j++) {
          if (aa[s[j] - 'a'][0] == mx && mx > 0) k--;
          if (aa[s[j] - 'a'][0] != -1) aa[s[j] - 'a'][0] = -1, count++;
          if (k == 0 || count == 25) slove(mx, k);
          if (k == 1) _slove(mx), flag = 1;
        }
      } else {
        a++;
        for (int j = 0; j < m; j++) {
          if (aa[s[j] - 'a'][0] != -1 && aa[s[j] - 'a'][1] != a) {
            aa[s[j] - 'a'][1] = a;
            aa[s[j] - 'a'][0]++;
            if (aa[s[j] - 'a'][0] > mx) {
              mx = aa[s[j] - 'a'][0];
              k = 1;
            } else if (aa[s[j] - 'a'][0] == mx)
              k++;
          }
        }
        if (k == 1) _slove(mx), flag = 1;
      }
    }
  }
  printf("%d\n", rs);
  return 0;
}
