#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string w;
  int shocks = 0, necessary = 0, flag = 0, flag1 = 0;
  char action;
  int no[26] = {0};
  int may[26] = {0};
  for (int i = 0; i < n; ++i) {
    cin >> action;
    int sum = accumulate(may, may + 26, 0);
    int sum1 = accumulate(no, no + 26, 0);
    if ((sum == 1 || sum1 == 25) && flag == 0) {
      necessary = shocks;
      flag = 1;
    }
    if (action == '.') {
      cin >> w;
      for (int j = 0; j < w.length(); ++j) {
        if (no[w[j] - 97] == 0) ++no[w[j] - 97];
        if (may[w[j] - 97] == 1) --may[w[j] - 97];
      }
    } else if (action == '!') {
      cin >> w;
      if (flag1 == 0) {
        for (int j = 0; j < w.length(); ++j) {
          if (may[w[j] - 97] == 0 && no[w[j] - 97] == 0) ++may[w[j] - 97];
        }
        for (int j = 0; j < 26; ++j) {
          if (w.find(char(j + 97)) == std::string::npos) no[j] = 1;
        }
        flag1 = 1;
      } else {
        for (int j = 0; j < 26; ++j) {
          if (w.find(char(j + 97)) == std::string::npos && no[j] == 0 &&
              may[j] == 1) {
            ++no[j];
            --may[j];
          }
        }
      }
      ++shocks;
    } else {
      cin >> action;
      if (i == n - 1) break;
      if (no[action - 97] == 0) ++no[action - 97];
      if (may[action - 97] == 1) --may[action - 97];
      ++shocks;
    }
  }
  if (flag == 1)
    cout << shocks - necessary << endl;
  else
    cout << "0" << endl;
  return 0;
}
