#include <bits/stdc++.h>
using namespace std;
vector<int> canb(26);
vector<pair<string, string> > q;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < 26; i++) canb[i] = 1;
  for (int i = 0; i < n; i++) {
    string a, b;
    cin >> a >> b;
    q.push_back(make_pair(a, b));
  }
  fill(canb.begin(), canb.end(), 1);
  int fans = 0;
  int ans;
  ans = q[q.size() - 1].second[0] - 'a';
  for (int i = 0; i < q.size(); i++) {
    string a, b;
    a = q[i].first;
    b = q[i].second;
    vector<int> charac(26);
    fill(charac.begin(), charac.end(), 0);
    for (int j = 0; j < b.size(); j++) charac[b[j] - 'a'] = 1;
    int totalcanb = 0;
    for (int j = 0; j < 26; j++)
      if (canb[j] == 1) totalcanb++;
    if (totalcanb == 1) {
      if (a[0] == '.')
        continue;
      else if (a[0] == '!') {
        fans++;
        continue;
      } else {
        if (b[0] != ans + 'a') {
          fans++;
          continue;
        }
      }
    }
    if (a[0] == '!') {
      for (int j = 0; j < 26; j++) {
        if (charac[j] == 0) canb[j] = 0;
      }
    } else if (a[0] == '.') {
      for (int j = 0; j < 26; j++) {
        if (charac[j] == 1) canb[j] = 0;
      }
    } else if (a[0] == '?') {
      canb[b[0] - 'a'] = 0;
      continue;
    }
  }
  cout << fans << endl;
}
