#include <bits/stdc++.h>
using namespace std;
bool f[100001];
char v[1000001];
int main() {
  int ok = 0;
  int val = 0;
  for (int i = 0; i < 26; i++) f[i] = 1;
  char ch;
  int n;
  cin >> n;
  for (int i = 0; i < 26; i++) f[i] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> ch;
    cin.get();
    cin.get(v, 100001);
    if (ch == '.') {
      int k = strlen(v);
      for (int j = 0; j < k; j++) f[v[j] - 'a'] = 0;
    }
    if (ch == '!') {
      if (ok == 1) val++;
      int k = strlen(v);
      bool cp[27];
      for (int j = 0; j < 26; j++) cp[j] = 0;
      for (int j = 0; j < k; j++) cp[v[j] - 'a'] = 1;
      for (int j = 0; j < 26; j++)
        if (cp[j] == 0) f[j] = 0;
    }
    if (ch == '?') {
      if (ok == 1 && f[v[0] - 'a'] == 0)
        val++;
      else
        f[v[0] - 'a'] = 0;
    }
    int s = 0;
    for (int i = 0; i < 26; i++) s += f[i];
    if (s == 1) ok = 1;
  }
  cout << val;
  return 0;
}
