#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
const double PI = acos(-1.0);
const long long mod = 1e18;
const int MAXN = 100000 + 5;
const int INF = 0x3f3f3f3f;
const int N = 100 + 10;
int main() {
  ios::sync_with_stdio(false);
  int n, f[26], num = 0, ans = 0;
  char opr;
  bool flag = false;
  string s;
  cin >> n;
  memset(f, 0, sizeof f);
  for (int i = 0; i < n; i++) {
    cin >> opr >> s;
    if (opr == '!') {
      if (flag) {
        ans++;
      }
      int tmp[26];
      memset(tmp, 0, sizeof tmp);
      for (int k = 0; k < s.length(); k++) {
        tmp[s[k] - 'a'] = 1;
      }
      for (int k = 0; k < 26; k++) {
        if (tmp[k] == 0) f[k] = -1;
      }
    } else if (opr == '.') {
      for (int k = 0; k < s.length(); k++) {
        f[s[k] - 'a'] = -1;
      }
    } else {
      if (flag && f[s[0] - 'a'] == -1) ans++;
      f[s[0] - 'a'] = -1;
    }
    num = 0;
    for (int k = 0; k < 26; k++) {
      if (f[k] != -1) num++;
    }
    if (num == 1) flag = true;
  }
  cout << ans << endl;
  return 0;
}
