#include <bits/stdc++.h>
using namespace std;
int a[26], l[26], n, k, x, se, t;
char b;
string s;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b >> s;
    if (x == 1) {
      if (i == n - 1) break;
      if (b != '.') se++;
      continue;
    }
    if (b != '?')
      for (int j = 0; j < s.size(); j++) l[s[j] - 'a']++;
    if (b == '!') {
      for (int j = 0; j < s.size(); j++) {
        a[s[j] - 'a']++;
      }
    }
    if (b == '.') {
      for (int j = 0; j < s.size(); j++) {
        a[s[j] - 'a']--;
      }
    }
    if (b == '?' && i != n - 1) a[s[0] - 'a']--;
    if (b != '?')
      for (int j = 0; j < 26; j++) {
        if (l[j] > 1) a[j] = a[j] - l[j] + 1;
        l[j] = 0;
      }
    k = 0;
    for (int j = 0; j < 26; j++) k = max(a[j], k);
    for (int j = 0; j < 26; j++)
      if (a[j] == k) t++;
    if (t == 1) x = 1;
    t = 0;
  }
  cout << se;
  return 0;
}
