#include <bits/stdc++.h>
using namespace std;
int main() {
  long N, Q;
  string s;
  cin >> N >> Q >> s;
  long l = 0, r = N;
  vector<pair<char, long>> v(Q);
  for (auto& i : v) {
    char c;
    cin >> i.first >> c;
    i.second = !(c & 2);
  }
  reverse(v.begin(), v.end());
  for (const auto& i : v) {
    if (i.second) {
      if (s[l] == i.first) ++l;
    } else {
      if (s[r - 1] == i.first) --r;
    }
  }
  cout << r - l << endl;
  return 0;
}
