#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int n, val[30], unq, duang;
char s[101000], t[101000];
int main() {
  scanf("%d", &n);
  for (int j = 0; j < 26; j++) val[j] = 1;
  unq = 0;
  for (int i = 0; i < n; i++) {
    scanf("%s%s", s, t);
    int l = strlen(t);
    if (s[0] == '?') {
      if (i == n - 1) {
        int id = t[0] - 'a';
        for (int j = 0; j < 26; j++) val[j] = j == id;
      } else {
        int id = t[0] - 'a';
        val[id] = 0;
        if (unq) duang += 1;
      }
    } else if (s[0] == '.') {
      for (int j = 0; j < l; j++) val[t[j] - 'a'] = 0;
    } else {
      if (unq) duang += 1;
      int S = 0;
      for (int j = 0; j < l; j++) S |= 1 << (t[j] - 'a');
      S ^= (1 << 26) - 1;
      for (int j = 0; j < 26; j++)
        if (S & (1 << j)) val[j] = 0;
    }
    int cnt = 0;
    for (int j = 0; j < 26; j++) cnt += val[j];
    if (cnt == 1) unq = 1;
  }
  printf("%d\n", duang);
}
