#include <bits/stdc++.h>
using namespace std;
long long n, i, j, k, l, sum = 0, flag = 0, ans = 0, a[100005], q = 0;
vector<long long int> v;
string s;
char c;
set<char> second, no;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> c >> s;
    if (c == '.') {
      for (auto j : s) {
        no.insert(j);
        if (q == 1) second.erase(j);
      }
    } else if (c == '?') {
      if (flag == 1) {
        ans++;
        continue;
      }
      no.insert(s[0]);
      if (q == 1) second.erase(s[0]);
      if ((long long)no.size() == 25LL || (q == 1 && second.size() == 1))
        flag = 1;
    } else {
      if (flag == 1) {
        ans++;
        continue;
      }
      sort((s).begin(), (s).end());
      for (char j = 'a'; j <= 'z'; j++) {
        if (no.find(j) != no.end()) {
          continue;
        }
        if (q == 0) {
          if (no.find(j) == no.end() &&
              binary_search((s).begin(), (s).end(), j))
            second.insert(j);
        } else {
          if ((second.find(j) != second.end() &&
               !(binary_search((s).begin(), (s).end(), j))) ||
              (second.find(j) == second.end() &&
               binary_search((s).begin(), (s).end(), j))) {
            second.erase(j);
            no.insert(j);
          }
        }
      }
      q = 1;
    }
    if ((long long)no.size() == 25LL || (q == 1 && second.size() == 1))
      flag = 1;
  }
  cout << max(0LL, ans - 1) << '\n';
  return 0;
}
