#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 7;
int n, t, ok = 0, len, ans = 0;
int is[30], add[30];
char str[N];
bool wait[30], in[30];
vector<int> V;
vector<pair<int, int> > tmp;
priority_queue<pair<int, int> > q;
void pre() {
  V.clear();
  for (int i = 2; i < (len); ++i) {
    t = (int)(str[i] - 'a');
    V.push_back(t);
  }
  sort((V).begin(), (V).end());
  V.erase(unique((V).begin(), (V).end()), V.end());
  for (int j = 0; j < ((int)(V).size()); ++j) {
    if (is[V[j]] && !in[V[j]]) {
      q.push(make_pair(1, V[j]));
      in[V[j]] = true;
    } else if (is[V[j]] && in[V[j]])
      add[V[j]] = 1;
  }
}
void deal() {
  tmp.clear();
  int cnt = q.size();
  for (int i = 0; i < (cnt); ++i) {
    pair<int, int> tt = q.top();
    q.pop();
    if (is[tt.second]) {
      if (add[tt.second])
        tmp.push_back(make_pair(tt.first + 1, tt.second));
      else
        tmp.push_back(tt);
    }
  }
  memset(add, 0, sizeof(add));
  memset(in, 0, sizeof(in));
  for (int i = 0; i < ((int)(tmp).size()); ++i) {
    q.push(tmp[i]);
    in[tmp[i].second] = 1;
  }
}
int main() {
  scanf("%d", &n);
  getchar();
  memset(in, 0, sizeof(in));
  memset(add, 0, sizeof(add));
  for (int i = 0; i < (30); ++i) is[i] = 1;
  int num = 26;
  for (int j = 1; j < n; j++) {
    gets(str);
    len = strlen(str);
    if (str[0] == '.') {
      if (ok) continue;
      for (int i = 2; i < (len); ++i) {
        t = (int)(str[i] - 'a');
        if (is[t] == 1) num--;
        is[t] = 0;
      }
    }
    if (str[0] == '?') {
      if (ok) {
        ans++;
        continue;
      } else {
        t = (int)str[2] - 'a';
        if (is[t] == 1) num--;
        is[t] = 0;
      }
    }
    if (str[0] == '!') {
      if (ok) {
        ans++;
        continue;
      }
      pre();
    }
    if (num == 1) ok = 1;
    if (!ok) {
      deal();
      if (q.empty())
        continue;
      else if (q.size() == 1)
        ok = 1;
      else {
        pair<int, int> t1 = q.top();
        q.pop();
        pair<int, int> t2 = q.top();
        if (t1.first > t2.first)
          ok = 1;
        else
          q.push(t1);
      }
    }
  }
  gets(str);
  cout << ans;
  return 0;
}
