#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
const int maxm = 100000 + 10;
const int mod = (int)1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LINF = (1LL << 62);
const double eps = 1e-8;
const double PI = acos(-1.0);
int f[30];
char w[maxn];
int check() {
  int cnt = 0, res;
  for (int i = 0; i < 26; i++)
    if (f[i] == 1) {
      cnt++;
      res = i;
    }
  if (cnt == 1) return res;
  if (cnt < 1) {
    int c = 0;
    for (int i = 0; i < 26; i++) {
      if (f[i] == 0) {
        c++;
        res = i;
      }
    }
    if (c == 1) return res;
  }
  return -1;
}
int main() {
  int n;
  scanf("%d", &n);
  int ans = 0, res = -1;
  bool flag = false;
  for (int i = 0; i < n; i++) {
    char op[5] = {0};
    scanf("%s", op);
    if (!flag) {
      res = check();
      if (~res) flag = true;
    }
    if (op[0] == '!') {
      scanf("%s", w);
      if (flag) {
        ans++;
        continue;
      }
      int len = strlen(w);
      bool hehe[30] = {0};
      for (int i = 0; i < len; i++) {
        int id = w[i] - 'a';
        hehe[id] = true;
      }
      for (int i = 0; i < 26; i++) {
        if (!hehe[i]) {
          f[i] = 2;
        } else if (f[i] == 0)
          f[i] = 1;
      }
    } else if (op[0] == '.') {
      scanf("%s", w);
      if (flag) continue;
      int len = strlen(w);
      for (int i = 0; i < len; i++) {
        f[w[i] - 'a'] = 2;
      }
    } else {
      scanf("%s", w);
      if (flag) {
        if (res != w[0] - 'a') ans++;
      } else {
        f[w[0] - 'a'] = 2;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
