#include <bits/stdc++.h>
const long long MX = 100 * 1000 + 1000, inf = 0x7FFFFFFF,
                mod = 1000 * 1000 * 1000 + 7;
using namespace std;
map<char, bool> mp, tmp;
long long n;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  long long tt = 0;
  char c = 'a';
  for (long long i = 0; i < 26; i++) {
    mp[c + i] = 1;
  }
  string t, m;
  for (long long i = 0; i < n - 1; i++) {
    cin >> t >> m;
    long long cntr = 0;
    bool tf = 0;
    for (long long j = 0; j < 26; j++) {
      cntr += mp[c + j];
    }
    if (cntr == 1) {
      tf = 1;
    }
    if (t[0] == '!') {
      for (long long j = 0; j < m.size(); j++) {
        tmp[m[j]] = 1;
      }
      for (long long j = 0; j < 26; j++) {
        mp[c + j] = mp[c + j] & tmp[c + j];
      }
      if (tf) {
        tt++;
      }
    } else if (t[0] == '.') {
      for (long long j = 0; j < m.size(); j++) {
        mp[m[j]] = 0;
      }
    } else {
      if (tf) {
        tt++;
      }
      mp[m[0]] = 0;
    }
    for (long long j = 0; j < 26; j++) {
      tmp[c + j] = 0;
    }
  }
  cin >> t >> m;
  cout << tt << endl;
}
