#include <bits/stdc++.h>
const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};
using namespace std;
bool can[500], was[500];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 'a'; i <= 'z'; i++) {
    can[i] = true;
  }
  string s;
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int i = 'a'; i <= 'z'; i++) cnt += can[i], was[i] = false;
    char ch;
    cin >> ch;
    if (ch == '!') {
      if (cnt == 1) ans++;
      cin >> s;
      for (int i = 0; i < (int)s.size(); i++) was[s[i]] = true;
      for (int i = 'a'; i <= 'z'; i++)
        if (!was[i]) can[i] = false;
    } else if (ch == '.') {
      cin >> s;
      for (int i = 0; i < (int)s.size(); i++) can[s[i]] = false;
    } else {
      char a;
      cin >> a;
      if (cnt == 1 && !can[a]) ans++;
      if (i != n) can[a] = false;
    }
  }
  cout << ans << endl;
  return 0;
}
