#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int sz = 1e5 + 10;
int ans, tot, n, fl;
string s1, s2;
bool ase[27];
bool bad[27];
bool check() {
  int cnt = 0;
  for (int i = 0; i < 26; i++) cnt += bad[i];
  return cnt == 1;
}
int main() {
  while (cin >> n) {
    tot = 0;
    ans = 0;
    fill(bad, bad + 26, 1);
    fl = 0;
    for (int i = 0; i < n; i++) {
      cin >> s1 >> s2;
      if (s1[0] == '!') {
        tot++;
        memset(ase, 0, sizeof ase);
        for (const char& c : s2) {
          ase[c - 'a'] = 1;
        }
        for (int i = 0; i < 26; i++) bad[i] &= ase[i];
      } else if (s1[0] == '.') {
        for (const char& c : s2) {
          bad[c - 'a'] = 0;
        }
      } else {
        if (i + 1 != n) {
          tot++;
          bad[s2[0] - 'a'] = 0;
        }
      }
      if (!fl) ans = tot;
      if (check()) fl = 1;
    }
    cout << tot - ans << "\n";
    cerr << "----------------\n";
  }
  return 0;
}
