#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int N;
bitset<26> sus;
char word[maxn];
int len;
long long lowbit(long long x) { return x & -x; }
int check(bitset<26> b) {
  long long t = (long long)b.to_ulong();
  return bool(t == lowbit(t));
}
int main() {
  scanf("%d", &N);
  char op[5];
  sus.set();
  int ans = 0;
  for (int i = 1; i < N; i++) {
    scanf("%s %s", op, word + 1);
    len = (int)strlen(word + 1);
    if (!check(sus)) ans = 0;
    if (op[0] == '.') {
      for (int i = 1; i <= len; i++) {
        sus[word[i] - 'a'] = 0;
      }
    } else if (op[0] == '!') {
      bitset<26> tmp;
      tmp.reset();
      for (int i = 1; i <= len; i++) {
        tmp[word[i] - 'a'] = 1;
      }
      if (check(sus))
        ans++;
      else
        sus &= tmp;
    } else {
      ans += check(sus);
      for (int i = 1; i <= len; i++) {
        sus[word[i] - 'a'] = 0;
      }
    }
  }
  printf("%d\n", ans);
}
