#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, i, j, count;
  cin >> n >> q;
  count = n;
  int g[n];
  char a[n], t[q], d[q];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    g[i] = 1;
  }
  for (i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
    for (j = 0; j < n; j++) {
      if (a[j] == t[i]) {
        if (d[i] == 'L') {
          if (j == 0) {
            count = count - g[j];
            g[j] = 0;
          } else {
            g[j - 1] = g[j] + g[j - 1];
            g[j] = 0;
          }
        } else {
          if (j == n - 1) {
            count = count - g[j];
            g[j] = 0;
          } else {
            g[j + 1] = g[j] + g[j + 1];
            g[j] = 0;
          }
        }
      }
    }
  }
  cout << count;
  return 0;
}
