#include <bits/stdc++.h>
using namespace std;
constexpr int N = 40 + 10;
int n, cnt = 26, ans;
bool mark[N], f, have[N];
string s;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    memset(have, 0, sizeof(have));
    if (s == "?") {
      cin >> s;
      if (f) {
        if (mark[s[0] - 'a']) ans++;
      } else {
        if (!mark[s[0] - 'a']) {
          cnt--;
          mark[s[0] - 'a'] = true;
          if (cnt == 1) f = true;
        }
      }
    } else if (s == ".") {
      cin >> s;
      for (auto j : s) {
        if (!mark[j - 'a']) {
          cnt--;
          mark[j - 'a'] = true;
        }
      }
      if (cnt == 1) f = true;
    } else {
      cin >> s;
      if (f) {
        ans++;
        continue;
      }
      for (auto j : s) have[j - 'a'] = true;
      for (int i = 0; i < 26; i++) {
        if (!have[i] && !mark[i]) {
          mark[i] = true;
          cnt--;
        }
      }
      if (cnt == 1) f = true;
    }
  }
  cout << ans << '\n';
  return 0;
}
