#include <bits/stdc++.h>
using namespace std;
map<char, bool> m;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  bool gu = false;
  int ans = 0;
  for (int i = 0; i < 26; i++) {
    m[i + 'a'] = true;
  }
  while (n--) {
    if (n == 0) break;
    char ch;
    cin >> ch;
    bool sh = false;
    int po = 0;
    for (auto x : m) po += x.second;
    if (po <= 1) gu = 1;
    if (ch == '?') {
      cin >> ch;
      if (n != 0) {
        sh = true;
        if (m.count(ch)) m.erase(ch);
      }
    } else {
      string str;
      cin >> str;
      if (ch == '!') sh = true;
      if (ch == '!') {
        map<char, bool> ww;
        for (auto x : str) ww[x] = true;
        for (int i = 0; i < 26; i++)
          if (!ww[i + 'a'] && m.count(i + 'a')) m.erase(i + 'a');
      } else {
        map<char, bool> ww;
        for (auto x : str) ww[x] = true;
        for (auto u : ww)
          if (m.count(u.first)) m.erase(u.first);
      }
    }
    if (gu && sh) ans++;
  }
  cout << ans << endl;
  return 0;
}
