#include <bits/stdc++.h>
using namespace std;
long long n, ff = 1, c = 0, ans = 2e16, res = 0;
char ch, ans_ch = '#';
string word;
void solve() {
  cin >> n;
  long long f[26] = {0};
  for (long long i = 1; i <= n; i++) {
    cin >> ch >> word;
    if (ch == '?' && i > ans) {
      res++;
      continue;
    }
    if (ch == '!' && i > ans && word.find(ans_ch) != string::npos) {
      res++;
      continue;
    }
    set<char> st;
    for (auto e : word) st.insert(e);
    if (ch == '!') {
      for (auto e : st) f[e - 'a']++;
      c++;
    } else if (ch == '.') {
      for (auto e : st) f[e - 'a']--;
    } else if (ch == '?' && i < n) {
      f[word[0] - 'a']--;
    }
    long long d = 0;
    for (long long j = 0; j < 26; j++) {
      if (f[j] == c) d++;
    }
    if (d == 1 && ff) {
      ans = i;
      ff = 0;
      for (long long j = 0; j < 26; j++)
        if (f[j] == c) ans_ch = j + 'a';
    }
  }
  res--;
  cout << max(0ll, res) << endl;
}
int main() {
  long long tests = 1;
  while (tests--) solve();
}
