#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int MOD = 1000000007;
const int UNDEF = -1;
const int INF = 1 << 30;
template <typename T>
inline bool chkmax(T &aa, T bb) {
  return aa < bb ? aa = bb, true : false;
}
template <typename T>
inline bool chkmin(T &aa, T bb) {
  return aa > bb ? aa = bb, true : false;
}
int rint();
char rch();
long long rlong();
const int mc = 26;
int no = 0, tmp = 0;
const int mn = 1e5 + 4;
string tp[mn];
string a[mn];
vector<pair<int, pair<int, int> > > v;
vector<pair<int, pair<int, int> > > vbang;
const int MASK = (1 << 26) - 1;
int fl(int x) { return (~x) & MASK; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> tp[i] >> a[i];
  }
  int allshocks = 0;
  for (int tt = 0; tt < n; tt++) {
    string s = a[tt];
    char t = tp[tt][0];
    if ((t == '!' || t == '?') && tt != n - 1) allshocks++;
  }
  int shocks = 0;
  int final = INF;
  for (int tt = 0; tt < n; tt++) {
    string s = a[tt];
    char t = tp[tt][0];
    if ((t == '!' || t == '?') && tt != n - 1) shocks++;
    if (t == '!') {
      int bang = 0;
      for (int x = 0; x < s.length(); x++) {
        int c = s[x] - 'a';
        bang |= (1 << c);
      }
      vbang.push_back(make_pair(tt, make_pair(bang, shocks)));
      int newno = no | fl(bang);
      if (newno != no) {
        v.push_back(make_pair(tt, make_pair(newno, shocks)));
      }
      no = newno;
    } else if (t == '.') {
      int dot = 0;
      for (int x = 0; x < s.length(); x++) {
        int c = s[x] - 'a';
        dot |= (1 << c);
      }
      int newno = no | dot;
      if (newno != no) {
        v.push_back(make_pair(tt, make_pair(newno, shocks)));
      }
      no = newno;
    } else if (t == '?') {
      int ques = 0;
      int c = s[0] - 'a';
      ques |= (1 << c);
      int newno = no | ques;
      if (newno != no) {
        v.push_back(make_pair(tt, make_pair(newno, shocks)));
      }
      no = newno;
    } else
      assert(0);
    if (__builtin_popcount(no) == mc - 1) {
      chkmin(final, shocks);
    }
  }
  for (auto &w : v) {
    int wi = w.first;
    int wno = w.second.first;
    int wshock = w.second.second;
    for (auto &b : vbang) {
      int bi = b.first, bang = b.second.first, bshock = b.second.second;
      int sig = fl(wno) & bang;
      if (__builtin_popcount(sig) <= 1) {
        chkmin(final, max(wshock, bshock));
        break;
      }
    }
  }
  int ans = shocks - final;
  chkmax(ans, 0);
  printf("%d\n", ans);
}
static char stdinBuffer[1024];
static char *stdinDataEnd = stdinBuffer + sizeof(stdinBuffer);
static const char *stdinPos = stdinDataEnd;
void readAhead(size_t amount) {
  size_t remaining = stdinDataEnd - stdinPos;
  if (remaining < amount) {
    memmove(stdinBuffer, stdinPos, remaining);
    size_t sz = fread(stdinBuffer + remaining, 1,
                      sizeof(stdinBuffer) - remaining, stdin);
    stdinPos = stdinBuffer;
    stdinDataEnd = stdinBuffer + remaining + sz;
    if (stdinDataEnd != stdinBuffer + sizeof(stdinBuffer)) *stdinDataEnd = 0;
  }
}
int rint() {
  readAhead(16);
  int x = 0;
  bool neg = false;
  while (*stdinPos == ' ' || *stdinPos == '\n') ++stdinPos;
  if (*stdinPos == '-') {
    ++stdinPos;
    neg = true;
  }
  while (*stdinPos >= '0' && *stdinPos <= '9') {
    x *= 10;
    x += *stdinPos - '0';
    ++stdinPos;
  }
  return neg ? -x : x;
}
char rch() {
  readAhead(16);
  while (*stdinPos == ' ' || *stdinPos == '\n') ++stdinPos;
  char ans = *stdinPos;
  ++stdinPos;
  return ans;
}
long long rlong() {
  readAhead(32);
  long long x = 0;
  bool neg = false;
  while (*stdinPos == ' ' || *stdinPos == '\n') ++stdinPos;
  if (*stdinPos == '-') {
    ++stdinPos;
    neg = true;
  }
  while (*stdinPos >= '0' && *stdinPos <= '9') {
    x *= 10;
    x += *stdinPos - '0';
    ++stdinPos;
  }
  return neg ? -x : x;
}
