#include <bits/stdc++.h>
using namespace std;
int read_word();
int bits(int n);
int main() {
  const int all = (1 << 26) - 1;
  int possible = all;
  int actions;
  cin >> actions;
  bool singular = false;
  int ret = 0;
  for (int action = 0; action + 1 < actions; action++) {
    char op;
    cin >> op;
    if (op == '.') {
      int word = read_word();
      possible &= ~word;
    } else if (op == '!') {
      int word = read_word();
      if (singular) ret++;
      possible &= word;
    } else {
      if (singular) ret++;
      char guess;
      cin >> guess;
      possible &= ~(1 << (guess - 'a'));
    }
    if (bits(possible) == 1) singular = true;
  }
  cout << ret << '\n';
}
int read_word() {
  int ret = 0;
  string word;
  cin >> word;
  for (int i = 0; i < word.size(); i++) ret |= 1 << (word[i] - 'a');
  return ret;
}
int bits(int n) {
  int ret = 0;
  while (n) {
    if (n & 1) ret++;
    n /= 2;
  }
  return ret;
}
