#include <bits/stdc++.h>
#pragma GCC optimize("omit-frame-pointer")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long N = 1100000;
const long double pi = atan(1) * 4;
const long long md = (1e9) + 7;
const long long mx = (1e18);
long long n, m, k, l, w, j, res, i, f[N], d[N], c[N];
char o, bu, bb;
string s;
int main() {
  ios_base ::sync_with_stdio(0);
  cin >> n;
  for (i = 1; i <= 26; i++) d[i + 'a' - 1] = 1;
  for (i = 1; i <= n; i++) {
    cin >> o;
    if (o == '!') {
      cin >> s;
      for (j = 1; j <= 26; j++) c[j + 'a' - 1] = 0;
      for (j = 0; j < s.size(); j++) c[s[j]] = 1;
      for (j = 1; j <= 26; j++)
        if (c[j + 'a' - 1] == 0) d[j + 'a' - 1] = 0;
      if (w) res++;
    }
    if (o == '.') {
      cin >> s;
      for (j = 0; j < s.size(); j++) d[s[j]] = 0;
    }
    if (o == '?') {
      cin >> bb;
      if (w && bb != bu) res++;
      d[bb] = 0;
    }
    k = 0;
    for (j = 1; j <= 26; j++)
      if (d[j + 'a' - 1] == 1) {
        k++;
        bu = j + 'a' - 1;
      }
    if (k == 1) w = 1;
  }
  cout << res;
}
