#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> used(26, 1);
  int maxShow = 0, ans = 0;
  int beat = 0;
  for (int i = 0; i < n; i++) {
    char type;
    string s;
    beat = accumulate(used.begin(), used.end(), 0);
    cin >> type >> s;
    if (type == '!') {
      if (beat == 1) {
        ans++;
      }
      vector<int> data(26, 0);
      for (const char& c : s) {
        data[c - 'a'] = 1;
      }
      for (int j = 0; j < 26; j++) {
        used[j] = min(used[j], data[j]);
      }
    } else if (type == '.') {
      for (const char& c : s) {
        used[c - 'a'] = 0;
      }
    } else if (type == '?') {
      if (beat == 1) {
        ans++;
      }
      used[s[0] - 'a'] = 0;
    }
  }
  cout << max(ans - 1, 0) << "\n";
  return 0;
}
