#include <bits/stdc++.h>
using namespace std;
char s[100010];
int check[30], ans = 0, tim = 0;
bool flag = false;
int main() {
  int n;
  scanf("%d", &n);
  memset(check, 0, sizeof(check));
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    if (s[1] == '!') {
      scanf("%s", s + 1);
      if (flag) {
        ans++;
        continue;
      }
      int len = strlen(s + 1);
      tim++;
      for (int i = 1; i <= len; i++) {
        int c = s[i] - 'a';
        if (check[c] == -1) continue;
        check[c] = tim;
      }
      for (int i = 0; i < 26; i++)
        if (check[i] != tim) check[i] = -1;
    }
    if (s[1] == '?') {
      scanf("%s", s + 1);
      if (flag) {
        ans++;
        continue;
      }
      int c = s[1] - 'a';
      check[c] = -1;
    }
    if (s[1] == '.') {
      scanf("%s", s + 1);
      int len = strlen(s + 1);
      for (int i = 1; i <= len; i++) {
        int c = s[i] - 'a';
        check[c] = -1;
      }
    }
    if (!flag) {
      int num = 0;
      for (int i = 0; i < 26; i++)
        if (check[i] != -1) num++;
      if (num == 1) flag = true;
    }
  }
  printf("%d", max(ans - 1, 0));
}
