#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, sum = 0, best = 1000000;
  cin >> n;
  vector<int> u(26, 1);
  for (int i = 0; i < n; i++) {
    char sy;
    string s;
    cin >> sy;
    cin >> s;
    if (sy == '!') {
      sum++;
      vector<int> u1(26);
      for (int j = 0; j < s.size(); j++) {
        if (u[s[j] - 'a'] == 1 || i == 0) u1[s[j] - 'a'] = 1;
      }
      u = u1;
    } else if (sy == '.') {
      for (int j = 0; j < s.size(); j++) u[s[j] - 'a'] = 0;
    } else {
      if (i < n - 1) sum++;
      if (i < n - 1) u[s[0] - 'a'] = 0;
    }
    int k = 0;
    for (int i = 0; i < 26; i++) {
      if (u[i] == 1) k++;
    }
    if (k == 1 && best == 1000000) best = sum;
  }
  cout << max(0, sum - best);
}
