#include <bits/stdc++.h>
using namespace std;
set<char> susp, dele;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  int cnt = 0;
  bool cl = 0;
  char corr;
  for (int i = (1); i <= (n); ++i) {
    char tp;
    cin >> tp;
    if (tp == '.') {
      string s;
      cin >> s;
      for (int i = (0); i <= (((int)(s).size()) - 1); ++i) {
        susp.erase(s[i]);
        dele.insert(s[i]);
      }
    }
    if (tp == '!') {
      string s;
      cin >> s;
      if (!((int)(susp).size())) {
        for (int i = (0); i <= (((int)(s).size()) - 1); ++i) {
          if (dele.find(s[i]) == dele.end()) susp.insert(s[i]);
        }
      } else {
        vector<char> todel;
        for (auto it : susp) {
          bool is = 0;
          for (int i = (0); i <= (((int)(s).size()) - 1); ++i)
            if (it == s[i]) is = 1;
          if (!is) todel.emplace_back((it));
        }
        for (int i = (0); i <= (((int)(todel).size()) - 1); ++i) {
          susp.erase(todel[i]);
          dele.insert(todel[i]);
        }
      }
    }
    char c;
    if (tp == '?') {
      cin >> c;
      susp.erase(c);
      dele.insert(c);
    }
    if (cl && (tp == '!' || (tp == '?' && c != corr))) ++cnt;
    if (!cl && ((int)(susp).size()) == 1) cl = 1, corr = *susp.begin();
    if (!cl && ((int)(dele).size()) == 25) {
      cl = 1;
      for (int i = ('a'); i <= ('z'); ++i)
        if (dele.find(i) == dele.end()) corr = i;
    }
  }
  cout << cnt << '\n';
  return 0;
}
