#include <bits/stdc++.h>
using namespace std;
int const K = 26;
int n;
vector<string> a, b;
char c;
int can[K];
int ans;
int have[K];
bool calc(string &s) {
  for (int i = 0; i < (int)(s.size()); ++i) {
    if (can[s[i] - 'a']) return false;
  }
  return true;
}
void solve() {
  c = b.back()[0];
  for (int i = 0; i < K; ++i) can[i] = 1;
  bool f = false;
  for (int i = 0; i < n; ++i) {
    if (f) {
      if (a[i][0] == '!') {
        ++ans;
      } else if (a[i][0] == '.') {
      } else {
        if (!can[b[i][0] - 'a']) ++ans;
      }
    } else {
      if (a[i][0] == '!') {
        if (f)
          ++ans;
        else
          ans += calc(b[i]);
        for (int j = 0; j < K; ++j) have[j] = 0;
        for (int j = 0; j < (int)(b[i].size()); ++j) have[b[i][j] - 'a'] = 1;
        for (int j = 0; j < K; ++j) can[j] &= have[j];
      } else if (a[i][0] == '.') {
        for (int j = 0; j < K; ++j) have[j] = 0;
        for (int j = 0; j < (int)(b[i].size()); ++j) have[b[i][j] - 'a'] = 1;
        for (int j = 0; j < K; ++j) can[j] &= (1 - have[j]);
      } else {
        can[b[i][0] - 'a'] = 0;
      }
    }
    int q = 0;
    for (int j = 0; j < K; ++j) q += can[j];
    if (q == 1) f = true;
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s0, s1;
    cin >> s0 >> s1;
    a.push_back(s0);
    b.push_back(s1);
  }
  solve();
  printf("%d\n", ans);
  return 0;
}
