#include <bits/stdc++.h>
using namespace std;
struct BlockInfo {
  char s;
  int gorem_num;
  BlockInfo() { gorem_num = 1; }
};
int main() {
  int N, Q;
  cin >> N >> Q;
  vector<BlockInfo> gorem_map(N);
  for (int i = 0; i < N; i++) {
    cin >> gorem_map[i].s;
  }
  for (int i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    int direction;
    if (d == 'L') {
      direction = -1;
    } else if (d == 'R') {
      direction = 1;
    } else {
      continue;
    }
    for (int i = 0; i < N; i++) {
      if (gorem_map[i].s != t) {
        continue;
      }
      int idx = i + direction;
      if (idx >= 0 && idx < N) {
        gorem_map[idx].gorem_num += gorem_map[i].gorem_num;
      }
      gorem_map[i].gorem_num = 0;
    }
  }
  int total = 0;
  for (int i = 0; i < N; i++) {
    total += gorem_map[i].gorem_num;
  }
  cout << total << endl;
  return 0;
}
