#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  bool let[26];
  memset(let, 1, sizeof(let));
  int count = 0;
  char who = -1;
  for (int i = 0; i < n; ++i) {
    char type;
    cin >> type;
    string st;
    cin >> st;
    if (type == '?') {
      if (st[0] != who && who != -1) ++count;
      let[st[0] - 'a'] = false;
    } else if (type == '.') {
      for (int i = 0; i < st.size(); ++i) let[st[i] - 'a'] = false;
    } else {
      bool arr[26] = {};
      for (int i = 0; i < st.size(); ++i) arr[st[i] - 'a'] = true;
      for (int i = 0; i < 26; ++i)
        if (!arr[i]) let[i] = false;
      if (who != -1) ++count;
    }
    if (who == -1) {
      for (int i = 0; i < 26; ++i)
        if (let[i]) {
          if (who == -1)
            who = i + 'a';
          else {
            who = -1;
            break;
          }
        }
    }
  }
  cout << count << endl;
  return 0;
}
