#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b, long long m) {
  a %= m;
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ((ret % m) * (a % m)) % m;
    a = ((a % m) * (a % m)) % m;
    b >>= 1;
  }
  return ret;
}
int sense[26];
vector<char> v;
int main() {
  int n;
  scanf("%d", &n);
  int point = -1;
  int shocks = 0;
  int flag = 0;
  for (char ch = 'a'; ch <= 'z'; ch++) v.push_back(ch);
  for (int i = 1; i <= n; i++) {
    char ch;
    cin >> ch;
    if (ch == '.') {
      string s;
      cin >> s;
      for (char ch1 : s) {
        sense[ch1 - 'a'] = -1;
      }
    } else if (ch == '!') {
      string s;
      cin >> s;
      shocks++;
      vector<char> vv;
      for (char ch1 : s) {
        int sig = 0;
        for (char ch2 : v) {
          if (ch1 == ch2) sig = 1;
        }
        if (sig) vv.push_back(ch1);
      }
      sort(vv.begin(), vv.end());
      v.clear();
      int tmp = unique(vv.begin(), vv.end()) - vv.begin();
      for (int i = 0; i < tmp; i++) v.push_back(vv[i]);
    } else {
      char ch1;
      cin >> ch1;
      if (i == n) break;
      shocks++;
      if (i != n) sense[ch1 - 'a'] = -1;
    }
    if (flag) continue;
    int sig = 0;
    int p = 0;
    vector<char> gg;
    for (int i = 0; i < v.size(); i++) {
      if (sense[v[i] - 'a'] == -1) continue;
      p++;
      gg.push_back(v[i]);
    }
    if (p == 1) sig = 1;
    if (sig) {
      point = shocks;
      flag = 1;
    }
    v = gg;
  }
  if (point == -1)
    cout << 0;
  else
    cout << shocks - point;
  return 0;
}
