#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5;
char tipo[MAXN + 2];
string w[MAXN + 2];
int calcula(int n, char c) {
  for (int i = 1; i < n; i++) {
    if (tipo[i] == '?') {
      if (w[i][0] == c) return i;
    } else if (tipo[i] == '!') {
      if (w[i].find(c) == string::npos) return i;
    } else {
      if (w[i].find(c) != string::npos) return i;
    }
  }
  return n;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> tipo[i];
    cin >> w[i];
  }
  int maximo = 0;
  for (char i = 'a'; i <= 'z'; i++) {
    if (i == w[n][0]) continue;
    maximo = max(maximo, calcula(n, i));
  }
  int resp = 0;
  for (int i = maximo + 1; i < n; i++) {
    if (tipo[i] == '!' || tipo[i] == '?') resp++;
  }
  cout << resp << "\n";
  return 0;
}
