#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> word;
  vector<char> chr;
  string b;
  char a;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    chr.push_back(a);
    word.push_back(b);
  }
  if (n == 1) {
    cout << "0";
    return 0;
  }
  char f = b[0];
  set<char> st;
  set<char> nhoi;
  int hold = 0, countt = 0, flag = 0;
  for (int i = 0; i < n - 1; i++) {
    if (chr[i] == '!') {
      if (st.size() == 0) {
        for (int j = 0; j < word[i].length(); j++) {
          if (nhoi.find(word[i][j]) == nhoi.end()) st.insert(word[i][j]);
        }
      } else {
        set<char> pt;
        for (int j = 0; j < word[i].length(); j++) {
          pt.insert(word[i][j]);
        }
        set<char>::iterator it, it2;
        vector<char> vec2;
        for (it = st.begin(); it != st.end(); it++) {
          if (pt.find(*it) == pt.end()) {
            vec2.push_back(*it);
          }
        }
        for (int k = 0; k < vec2.size(); k++) {
          st.erase(vec2[k]);
        }
      }
    } else if (chr[i] == '.') {
      for (int j = 0; j < word[i].length(); j++) {
        nhoi.insert(word[i][j]);
        if (st.find(word[i][j]) != st.end()) {
          st.erase(word[i][j]);
        }
      }
    } else {
      for (int j = 0; j < word[i].length(); j++) {
        nhoi.insert(word[i][j]);
        if (st.find(word[i][j]) != st.end()) {
          st.erase(word[i][j]);
        }
      }
    }
    if ((st.size() == 1 && *(st.begin()) == f) || nhoi.size() == 25) {
      hold = i;
      flag = 1;
      break;
    }
  }
  if (flag == 1) {
    for (int i = hold + 1; i < n - 1; i++) {
      if (chr[i] == '!' || chr[i] == '?') {
        countt++;
      }
    }
    cout << countt;
    return 0;
  }
  cout << "0";
  return 0;
}
