#include <bits/stdc++.h>
using namespace std;
const int inf = (1 << 30) - 1;
const int maxn = 100010;
int IN() {
  int c, f, x;
  while (!isdigit(c = getchar()) && c != '-')
    ;
  c == '-' ? (f = 1, x = 0) : (f = 0, x = c - '0');
  while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + c - '0';
  return !f ? x : -x;
}
int n, T;
char s[maxn];
bool vis[maxn], c[maxn];
bool check() {
  int ans = 0;
  for (int i = 0; i < 26; i++)
    if (vis[i]) ans++;
  return ans == 1;
}
int main() {
  scanf("%d", &n);
  int ans = 0;
  fill(vis, vis + maxn, 1);
  fill(c, c + maxn, 1);
  for (int i = 1; i <= n; i++) {
    char op[10];
    scanf("%s%s", op, s);
    char tp = op[0];
    int len = strlen(s);
    if (tp == '.') {
      for (int i = 0; i < len; i++) vis[s[i] - 'a'] = 0;
    } else if (tp == '!') {
      if (check()) ans++;
      int t[27];
      memset(t, 0, sizeof(t));
      for (int i = 0; i < len; i++) t[s[i] - 'a']++;
      for (int i = 0; i < 26; i++)
        if (!t[i]) vis[i] = 0;
    } else if (tp == '?') {
      if (i != n && check()) ans++;
      vis[s[0] - 'a'] = 0;
    }
  }
  printf("%d\n", ans);
  return 0;
}
