#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 50, maxm = 1e5 + 50;
const int inf = 0x3f3f3f3f, mod = (int)1e9 + 7;
const int sigma = 27;
const long long INF = 0x3f3f3f3f3f3f3f3f;
typedef int arrn[maxn];
typedef long long arrm[maxn];
int ch[30];
string s[maxn];
int n;
int main() {
  int i;
  cin >> n;
  getchar();
  for (i = 1; i <= n; ++i) getline(cin, s[i]);
  int flag = 0;
  for (i = 1; i < n; ++i) {
    if (s[i][0] == '.') {
      for (int j = 2; j < s[i].size(); ++j) ch[s[i][j] - 'a'] = 2;
    } else if (s[i][0] == '!') {
      if (!flag) {
        for (int j = 2; j < s[i].size(); ++j)
          if (ch[s[i][j] - 'a'] == 0) ch[s[i][j] - 'a'] = 1;
      } else {
        int gg[26] = {};
        for (int j = 2; j < s[i].size(); ++j) gg[s[i][j] - 'a'] = 1;
        for (int j = 0; j < 26; ++j)
          if (ch[j] != 1 || gg[j] != 1) ch[j] = 2;
      }
    } else {
      ch[s[i][2] - 'a'] = 2;
    }
    int cnt[3] = {0, 0, 0};
    for (int j = 0; j < 26; ++j) cnt[ch[j]]++;
    if (cnt[1] >= 1) flag = 1;
    if (cnt[1] == 1 || (cnt[0] == 1 && cnt[2] == 25)) break;
  }
  int ans = 0;
  for (++i; i < n; ++i)
    if (s[i][0] != '.') ans++;
  cout << ans;
}
