#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000;
int main() {
  long long int n, q;
  long long int dc = 0;
  char c[maxn], d[maxn];
  vector<vector<int>> aan(26);
  map<int, int> angn;
  string s;
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < q; i++) {
    cin >> c[i] >> d[i];
  }
  char le = s[0], re = s[n - 1];
  for (int i = 0; i < n; i++) {
    aan[(int)s[i] - 65].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    angn[i] = 1;
  }
  for (int i = 0; i < q; i++) {
    int aln = (int)c[i] - 65;
    for (int j = 0; j < aan[aln].size(); j++) {
      int tr = angn[aan[aln][j]];
      if ((aan[aln][j] == 0 && d[i] == 'L') ||
          (aan[aln][j] == n - 1 && d[i] == 'R')) {
        dc += angn[aan[aln][j]];
      } else if (d[i] == 'L') {
        angn[aan[aln][j] - 1] += tr;
      } else {
        angn[aan[aln][j] + 1] += tr;
      }
      angn[aan[aln][j]] = 0;
    }
  }
  cout << n - dc << endl;
  return 0;
}
