#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)1e9 + 7;
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  map<char, bool> m;
  for (char i = 'a'; i <= 'z'; i++) {
    m[i] = true;
  }
  bool first = true;
  int cnt = 0;
  while (t--) {
    char c;
    cin >> c;
    string s;
    if (c == '!') {
      cin >> s;
      if (m.size() == 1) {
        cnt++;
        continue;
      }
      stack<char> st;
      for (int i = 0; i < s.size(); i++) {
        if (m[s[i]]) {
          st.push(s[i]);
        }
      }
      m.clear();
      while (!st.empty()) {
        m[st.top()] = true;
        st.pop();
      }
    } else if (c == '.') {
      cin >> s;
      for (int i = 0; i < s.size(); i++) {
        m.erase(s[i]);
      }
    } else {
      char cc;
      cin >> cc;
      if (m.size() == 1 && m[cc] == false) {
        cnt++;
      }
      m.erase(cc);
    }
  }
  cout << cnt;
  return 0;
}
