#include <bits/stdc++.h>
using namespace std;
string t[100000];
char mm[100000];
int check[26];
int ans() {
  int m = 0, c = 0;
  for (int i = 0; i < 26; ++i) m = max(m, check[i]);
  for (int i = 0; i < 26; ++i) {
    if (check[i] == m) ++c;
    if (c > 1) return 0;
  }
  return 1;
}
int main() {
  int n, shock = 0, c = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> mm[i] >> t[i];
    if (mm[i] == '!' or mm[i] == '?') ++shock;
  }
  for (int i = 0; i < n - 1; ++i) {
    if (mm[i] == '.') {
      for (int j = 0; j < t[i].size(); ++j) check[t[i][j] - 'a'] = -1;
    }
    if (mm[i] == '!') {
      ++c;
      set<char> s;
      for (int j = 0; j < t[i].size(); ++j) {
        if (check[t[i][j] - 'a'] != -1) {
          if (s.find(t[i][j] - 'a') == s.end()) {
            s.insert(t[i][j] - 'a');
            ++check[t[i][j] - 'a'];
          }
        }
      }
    }
    if (mm[i] == '?') {
      ++c;
      check[t[i][0] - 'a'] = -1;
    }
    if (ans()) {
      cout << shock - c - 1;
      return 0;
    }
  }
  cout << '0';
}
