#include <bits/stdc++.h>
using namespace std;
bool c[30];
char s[10], t[100010];
map<int, bool> mp;
int flag = -1;
int ans;
int main() {
  int n;
  scanf("%d", &n);
  while (n--) {
    scanf("%s%s", s, t);
    if (s[0] == '!') {
      mp.clear();
      for (int i = 0; t[i]; i++) mp[(int)t[i] - 'a'] = 1;
      for (int i = 0; i < 26; i++)
        if (!mp[i]) c[i] = 1;
    } else if (s[0] == '?')
      c[t[0] - 'a'] = 1;
    else if (s[0] == '.')
      for (int i = 0; t[i]; i++) c[t[i] - 'a'] = 1;
    if (flag > -1 && (s[0] == '!' || (s[0] == '?' && t[0] != flag + 'a')))
      ++ans;
    if (flag == -1) {
      int tot = 0;
      for (int i = 0; i < 26; i++)
        if (c[i] == 0) ++tot, flag = i;
      if (tot > 1) flag = -1;
    }
  }
  cout << ans;
}
