#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long n, q, m, t, k, i, j, x, y, z, p, v, val = 0, minans = LLONG_MAX, a,
                                                b, c, d, flag = 0;
  cin >> n;
  char ch;
  string s;
  set<long long> possible;
  vector<long long> arr(26, 0);
  for (i = 0; i < n; i++) {
    cin >> ch;
    cin >> s;
    if (ch == '.') {
      for (j = 0; j < s.length(); j++) arr[s[j] - 'a'] = -1;
    } else if (ch == '!') {
      if (flag) val++;
      set<long long> temp;
      for (j = 0; j < s.length(); j++) temp.insert(s[j] - 'a');
      for (auto e : temp) {
        if (arr[e] != -1) {
          arr[e]++;
        }
      }
    } else {
      if (flag) val++;
      arr[s[0] - 'a'] = -1;
    }
    long long max1 = LLONG_MIN;
    for (j = 0; j < 26; j++) max1 = max(max1, arr[j]);
    possible.clear();
    for (j = 0; j < 26; j++) {
      if (arr[j] == max1) possible.insert(j);
    }
    if (possible.size() == 1) {
      flag = 1;
    }
  }
  if (val == 0) val++;
  cout << val - 1;
  return 0;
}
