#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long mod = 1000000007;
const double eps = 1e-7;
const double pi = acos(1.0 * (-1));
const double e = 2.718281828459;
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long pow_mod(long long a, long long b, long long c) {
  long long ans = 1;
  a = a % c;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % c;
    b = b / 2;
    a = (a * a) % c;
  }
  return ans;
}
double pow_mod_double(double a, int b) {
  double ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a);
    b = b / 2;
    a = (a * a);
  }
  return ans;
}
int pow_int(int a, int b) {
  int ans = 1;
  for (int i = 0; i < b; i++) ans *= a;
  return ans;
}
long long pow_llong(long long a, long long b) {
  long long ans = 1;
  for (int i = 0; i < b; i++) ans *= a;
  return ans;
}
double pow_double(double a, double b) {
  double ans = 1;
  for (int i = 0; i < b; i++) ans *= a;
  return ans;
}
const int dx[9] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int dy[9] = {0, 1, 0, -1, -1, -1, 0, 1, 1};
int Scan() {
  int res = 0, flag = 0;
  char ch;
  if ((ch = getchar()) == '-') {
    flag = 1;
  } else if (ch >= '0' && ch <= '9') {
    res = ch - '0';
  }
  while ((ch = getchar()) >= '0' && ch <= '9') {
    res = res * 10 + (ch - '0');
  }
  return flag ? -res : res;
}
void Out(int a) {
  if (a < 0) {
    putchar('-');
    a = -a;
  }
  if (a >= 10) {
    Out(a / 10);
  }
  putchar(a % 10 + '0');
}
long long jc(long long a, long long b, long long mod) {
  long long ans = 1;
  b = max(b, a - b);
  for (long long i = a; i > b; i--) {
    ans *= i;
    ans %= mod;
  }
  return ans;
}
double lg(double a) { return (log(a) / log(10.0)); }
inline int read() {
  int f = 1, x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
vector<char> ans;
char f[20];
char g[100100];
int tt[200];
int main() {
  for (int i = 0; i <= 25; i++) ans.push_back('a' + i);
  int t;
  int flag = 0;
  int anss = 0;
  scanf("%d", &t);
  for (int i = 'a'; i <= 'z'; i++) {
    tt[i]++;
  }
  for (int i = 1; i <= t; i++) {
    scanf("%s", f);
    scanf("%s", g);
    if (f[0] == '!') {
      if (flag) anss++;
      for (int i = 0; i <= ans.size() - 1; i++) {
        bool e = 0;
        for (int j = 0; j < strlen(g); j++) {
          if (g[j] == ans[i]) {
            e = true;
            break;
          }
        }
        if (!e) {
          tt[ans[i]] = 0;
          ans.erase(ans.begin() + i);
          i--;
        }
      }
    }
    if (f[0] == '.') {
      for (int i = 0; i <= ans.size() - 1; i++) {
        bool e = true;
        for (int j = 0; j < strlen(g); j++) {
          if (g[j] == ans[i]) {
            e = false;
            break;
          }
        }
        if (!e) {
          tt[ans[i]] = 0;
          ans.erase(ans.begin() + i);
          i--;
        }
      }
    }
    if (f[0] == '?' && t != i) {
      if (flag) anss++;
      if (tt[g[0]]) {
        for (int i = 0; i <= ans.size() - 1; i++) {
          if (ans[i] == g[0]) {
            tt[ans[i]] = 0;
            ans.erase(ans.begin() + i);
            break;
          }
        }
      }
    }
    if (ans.size() == 1) {
      flag = 1;
    }
  }
  printf("%d\n", anss);
  return 0;
}
