#include <bits/stdc++.h>
using namespace std;
int n, i, buc[26], cnt = 0, ok = 0, j, m, cntt = 0, dfn = 0, pre;
char a[2], s[100005];
int main() {
  scanf("%d", &n);
  pre = dfn;
  cntt = 26;
  for (i = 1; i <= n; i++) {
    scanf("%s%s", a, s);
    if (ok == 1) {
      if (a[0] == '!') cnt++;
      if (a[0] == '?') cnt++;
    } else {
      if (a[0] == '!') {
        dfn++;
        cntt = 0;
        m = strlen(s);
        for (j = 0; j < m; j++) {
          if (buc[s[j] - 'a'] == pre) {
            cntt++;
            buc[s[j] - 'a'] = dfn;
          }
        }
        if (cntt == 1) ok = 1;
        pre = dfn;
      }
      if (a[0] == '.') {
        m = strlen(s);
        for (j = 0; j < m; j++) {
          if (buc[s[j] - 'a'] == pre) {
            cntt--;
            buc[s[j] - 'a'] = pre - 1;
          }
        }
        if (cntt == 1) ok = 1;
      }
      if (a[0] == '?') {
        if (buc[s[0] - 'a'] == pre) {
          buc[s[0] - 'a'] = pre - 1;
          cntt--;
        }
        if (cntt == 1) ok = 1;
      }
    }
  }
  if (cnt)
    printf("%d", cnt - 1);
  else
    printf("0");
  return 0;
}
