#include <bits/stdc++.h>
using namespace std;
int n, M[100], ch;
char S[10], s[100100];
bool check() {
  int ans = 0, C = 0;
  for (int i = 1; i <= 26; i++)
    if (M[i] == 1) {
      ans++;
      C = i;
    }
  if (ans == 1) {
    ch = C;
    return 1;
  }
  return 0;
}
int main() {
  scanf("%d", &n);
  bool flag = false;
  int ans = 0;
  ch = 0;
  for (int i = 1; i <= 26; i++) M[i] = 1;
  while (n--) {
    scanf("%s%s", S, s);
    if (S[0] == '!') {
      int len = strlen(s);
      for (int i = 0; i < len; i++) {
        if (M[s[i] - 'a' + 1] == 1) M[s[i] - 'a' + 1] = 3;
      }
      for (int i = 1; i <= 26; i++)
        if (M[i] == 1) M[i] = 2;
      for (int i = 1; i <= 26; i++)
        if (M[i] == 3) M[i] = 1;
      if (flag) ans++;
      if (check()) flag = true;
    }
    if (S[0] == '.') {
      int len = strlen(s);
      for (int i = 0; i < len; i++) M[s[i] - 'a' + 1] = 2;
      if (check()) flag = true;
    }
    if (S[0] == '?') {
      if (flag) {
        if (ch != s[0] - 'a' + 1) ans++;
      } else {
        M[s[0] - 'a' + 1] = 2;
        if (check()) flag = true;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
