#include <bits/stdc++.h>
using namespace std;
struct node {
  string q, str;
};
node k[100005];
int n, ans, dtm, p[30], test[30], cnt;
bool flag;
int main(void) {
  flag = false;
  cin >> n;
  for (int i = 0; i < 26; i++) {
    p[i] = 1;
  }
  for (int i = 0; i < n; i++) {
    cin >> k[i].q >> k[i].str;
  }
  dtm = k[n - 1].str[0] - 'a';
  for (int i = 0; i < n; i++) {
    if (k[i].q[0] == '.') {
      int l = k[i].str.size();
      for (int j = 0; j < l; j++) {
        p[k[i].str[j] - 'a'] = 0;
      }
    } else if (k[i].q[0] == '!') {
      if (flag == true)
        ans++;
      else {
        memset(test, 0, sizeof(test));
        int l = k[i].str.size();
        for (int j = 0; j < l; j++) {
          test[k[i].str[j] - 'a'] = 1;
        }
        for (int j = 0; j < 26; j++) {
          if (test[j] == 0) p[j] = 0;
        }
      }
    } else {
      if (k[i].str[0] - 'a' != dtm) {
        if (flag == true)
          ans++;
        else {
          p[k[i].str[0] - 'a'] = 0;
        }
      }
    }
    if (flag == false) {
      cnt = 0;
      for (int i = 0; i < 26; i++) {
        if (p[i] == 1) cnt++;
      }
      if (cnt == 1) flag = true;
    }
  }
  cout << ans << endl;
  return 0;
}
