#include <bits/stdc++.h>
using namespace std;
struct node2 {
  int x;
  char y;
  int z;
} xx[200030];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> xx[i].y;
    xx[i].x = 1;
    xx[i].z = 0;
  }
  char a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    for (int j = 0; j < n; j++) {
      if (xx[j].y == a) {
        if (b == 'L') {
          if (j == 0) {
            xx[j].x = 0;
            continue;
          }
          xx[j - 1].x += xx[j].x;
          xx[j].x = 0;
        } else if (b == 'R') {
          while (xx[j].y == xx[j + 1].y) {
            xx[j + 1].z = xx[j].x;
            xx[j].x = xx[j].z;
            xx[j].z = 0;
            j++;
          }
          xx[j].x += xx[j].z;
          if (j == n - 1 && xx[j].y == a) {
            xx[j].x = 0;
            continue;
          }
          xx[j + 1].x += xx[j].x;
          xx[j].x = 0;
        }
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += xx[i].x;
  }
  cout << sum << endl;
  return 0;
}
