#include <bits/stdc++.h>
using namespace std;
int gogo[60] = {};
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < 26; ++i) {
    gogo[i] = 1;
  }
  int ans = 0;
  int do_all = -1;
  for (int i = 0; i < n; ++i) {
    string a, b;
    cin >> a >> b;
    if (a == "!") {
      if (do_all != -1) ans++;
      int gege[60] = {};
      for (int q = 0; q < b.length(); ++q) {
        gege[b[q] - 'a'] |= gogo[b[q] - 'a'];
      }
      for (int q = 0; q < 50; ++q) {
        gogo[q] = gege[q];
      }
    } else if (a == "?") {
      if (do_all != -1 && do_all != b[0] - 'a') ans++;
      gogo[b[0] - 'a'] = 0;
    } else if (a == ".") {
      for (int i = 0; i < b.length(); ++i) {
        gogo[b[i] - 'a'] = 0;
      }
    }
    int bad = -1;
    for (int i = 0; i < 26; ++i) {
      if (gogo[i]) {
        if (bad != -1)
          bad = 100;
        else
          bad = i;
      }
    }
    if (bad != 100) {
      do_all = bad;
    }
  }
  cout << ans << endl;
  return 0;
}
