#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, r, q, p;
  char t, d;
  string s;
  cin >> n >> q;
  r = n;
  cin >> s;
  int num[n], next[n];
  vector<int> go(n);
  for (i = 0; i < n; i++) {
    num[i] = 1;
    next[i] = 0;
    go[i] = i;
  }
  for (i = 0; i < q; i++) {
    cin >> t >> d;
    for (j = 0; j < go.size(); j++) {
      if (s[go[j]] == t) {
        p = go[j];
        next[p] = next[p] + num[p] * (-1);
        if (!(p == 0 && d == 'L') && !(p == n - 1 && d == 'R')) {
          if (d == 'R') {
            next[p + 1] = num[p];
            go[j]++;
            if (j != go.size()) {
              if (go[j] == go[j + 1]) go.erase(go.begin() + j);
            }
          } else {
            next[p - 1] = num[p];
            go[j]--;
            if (j != 0) {
              if (go[j] == go[j - 1]) go.erase(go.begin() + j);
            }
          }
        } else {
          r -= num[p];
          go.erase(go.begin() + j);
        }
      }
    }
    if (r == 0) break;
    for (j = 0; j < n; j++) {
      num[j] = num[j] + next[j];
      next[j] = 0;
    }
  }
  cout << r << endl;
  return 0;
}
