#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
char s[maxn];
int ok[30];
int check() {
  int cnt = 0;
  int cnt2 = 0;
  for (int i = 0; i < 26; ++i)
    if (ok[i] == 1)
      cnt++;
    else if (ok[i] == -1)
      cnt2++;
  if (cnt2 == 25) cnt = 1;
  return cnt;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < 26; ++i) ok[i] = 0;
  bool first = true;
  bool unq = false;
  int p;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    char ch[2];
    scanf("%s", ch);
    scanf("%s", s);
    int len = strlen(s);
    int cnt[30];
    memset(cnt, 0, sizeof cnt);
    for (int i = 0; i < len; ++i) {
      int t = s[i] - 'a';
      cnt[t]++;
    }
    if (ch[0] == '!') {
      if (unq) ans++;
      if (first) {
        first = false;
        for (int i = 0; i < len; ++i)
          if (ok[s[i] - 'a'] == 0) ok[s[i] - 'a'] = 1;
      }
      for (int i = 0; i < 26; ++i) {
        if (!cnt[i] && ok[i] == 1) ok[i] = -1;
      }
    } else if (ch[0] == '.') {
      for (int i = 0; i < 26; ++i) {
        if (cnt[i]) ok[i] = -1;
      }
    } else {
      if (!unq) ok[s[0] - 'a'] = -1;
      if (unq && i != n - 1) ans++;
    }
    if (check() == 1 && !unq) {
      unq = true;
      for (int i = 0; i < 26; ++i)
        if (ok[i] == 1) p = i;
    }
  }
  printf("%d\n", ans);
  return 0;
}
