#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979;
const double eps = 1e-15;
const long long _INF = 1e18;
const int INF = 1e9;
const int maxn = 100010;
const int maxm = 1000010;
int n, ans, cnt, idx;
int a[30];
char s[10], t[maxn];
bool isok;
bool vis[30];
int main(int argc, char const *argv[]) {
  while (~scanf("%d", &n)) {
    isok = false;
    ans = cnt = 0;
    memset(a, 0, sizeof(a));
    for (int i = 0; i < n; ++i) {
      scanf("%s %s", s, t);
      if (i == n - 1) break;
      if (isok) {
        if (!strcmp(s, "!"))
          ++ans;
        else if (!strcmp(s, "?"))
          ++ans;
      } else {
        if (!strcmp(s, "!")) {
          memset(vis, 0, sizeof(vis));
          for (int j = 0; t[j]; ++j)
            if (a[t[j] - 'a'] != -1 && !vis[t[j] - 'a']) {
              ++a[t[j] - 'a'];
              vis[t[j] - 'a'] = true;
            }
          ++cnt;
        } else if (!strcmp(s, ".")) {
          for (int j = 0; t[j]; ++j) a[t[j] - 'a'] = -1;
        } else if (!strcmp(s, "?"))
          a[t[0] - 'a'] = -1;
        int num = 0;
        for (int j = 0; j < 26; ++j)
          if (a[j] == cnt) {
            ++num;
            idx = j;
          } else
            a[j] = -1;
        if (num == 1) isok = true;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
