#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  char c;
  string s;
  int n;
  int a[26];
  memset(a, 0, sizeof(a));
  cin >> n;
  int ans = 0;
  bool valid = false;
  int dem = 0;
  for (int i = 0; i < n; i++) {
    cin >> c >> s;
    if (c == '!') {
      dem++;
      if (valid) ans++;
      bool marks[26];
      memset(marks, 0, sizeof(marks));
      for (int j = 0; j < s.length(); j++) {
        if (!marks[s[j] - 97]) {
          a[s[j] - 97]++;
          marks[s[j] - 97] = true;
        }
      }
    } else if (c == '.') {
      for (int j = 0; j < s.length(); j++) {
        a[s[j] - 97] = -1000000007;
      }
    } else if (c == '?') {
      a[s[0] - 97] = -1000000007;
      if (valid && i != n - 1) ans++;
    }
    int cnt = 0;
    for (int j = 0; j < 26; j++) {
      if (a[j] == dem) cnt++;
    }
    if (cnt == 1) valid = true;
  }
  cout << ans;
  return 0;
}
