#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 1e5 + 7;
long long n, ans;
char f;
string s;
int fl[1000], fll[1000], ff;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  int pa = (int)('a');
  int pz = (int)('z');
  for (int i = pa; i <= pz; i++) fl[i] = 1;
  for (int j = 0; j < n; j++) {
    cin >> f;
    cin >> s;
    if (ff && (f == '!' || f == '?')) ans++;
    if (f == '.') {
      for (int i = 0; i < s.size(); i++) fl[(int)(s[i])] = 0;
    }
    if (f == '!') {
      for (int i = 0; i < s.size(); i++) fll[(int)(s[i])] = 1;
      for (int i = pa; i <= pz; i++)
        if (!fll[i]) fl[i] = 0;
      for (int i = 0; i < s.size(); i++) fll[(int)(s[i])] = 0;
    }
    if (f == '?') {
      fl[(int)(s[0])] = 0;
    }
    int k = 0;
    for (int i = pa; i <= pz; i++) k += fl[i];
    if (k <= 1) {
      ff = 1;
    }
  }
  cout << max((long long)(0), ans - 1);
  return 0;
}
