#include <bits/stdc++.h>
using namespace std;
char s[5], a[100007];
int xx[27], yy[27];
int main() {
  int cnt = 26, n, i, j, flag = 0, nn, ans = 0;
  scanf("%d", &n);
  for (i = 0; i < 26; i++) xx[i] = 1;
  while (n--) {
    scanf("%s", s);
    scanf("%s", a);
    nn = strlen(a);
    if (flag == 0) {
      if (s[0] == 33) {
        for (i = 0; i < nn; i++) {
          yy[a[i] - 'a'] = 1;
        }
        for (i = 0; i < 26; i++) {
          if (yy[i] == 0) {
            if (xx[i] == 1) xx[i] = 0, cnt--;
          }
        }
        for (i = 0; i < 26; i++) {
          yy[i] = 0;
        }
      } else if (s[0] == 46) {
        for (i = 0; i < nn; i++) {
          yy[a[i] - 'a'] = -1;
        }
        for (i = 0; i < 26; i++) {
          if (yy[i] == -1) {
            if (xx[i] == 1) xx[i] = 0, cnt--;
          }
        }
        for (i = 0; i < 26; i++) {
          yy[i] = 0;
        }
      } else if (s[0] == 63) {
        if (xx[a[0] - 'a'] == 1) {
          xx[a[0] - 'a'] = 0;
          cnt--;
        }
      }
      if (cnt == 1) flag = 1;
    } else {
      if (s[0] == 33) ans++;
      if (s[0] == 63 && xx[a[0] - 'a'] == 0) ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
