#include <bits/stdc++.h>
using namespace std;
struct square {
  char c;
  int num;
};
int main() {
  int n, q;
  string s;
  cin >> n >> q;
  cin >> s;
  int count = 0;
  struct square ss[n];
  int i, j, k;
  for (i = 0; i < n; i++) {
    ss[i].c = s[i];
    ss[i].num = 1;
  }
  char t, d;
  for (i = 0; i < q; i++) {
    cin >> t >> d;
    if (d == 'L') {
      for (j = 0; j < n; j++) {
        if (ss[j].c == t) {
          if (j == 0) {
            if (ss[j].num > 0) ss[j].num = 0;
          } else {
            if (ss[j].num > 0) {
              ss[j - 1].num += ss[j].num;
              ss[j].num = 0;
            }
          }
        }
      }
    } else {
      for (j = n - 1; j >= 0; j--) {
        if (ss[j].c == t) {
          if (j == n - 1) {
            if (ss[j].num > 0) ss[j].num = 0;
          } else {
            if (ss[j].num > 0) {
              ss[j + 1].num += ss[j].num;
              ss[j].num = 0;
            }
          }
        }
      }
    }
  }
  for (i = 0; i < n; i++) {
    if (ss[i].num > 0) count += ss[i].num;
  }
  cout << count << endl;
  return 0;
}
