#include <bits/stdc++.h>
using namespace std;
int N, Q;
char s[200000 + 1];
int golems[200000];
class Pair {
 public:
  int first, second;
  Pair(int f, int s) { first = f, second = s; }
  bool operator<(const Pair& p) const { return first < p.first; }
};
vector<Pair> table;
int main(int argc, char** argv) {
  scanf("%d %d", &N, &Q);
  scanf("%s", s);
  for (int i = 0; i < N; ++i) {
    table.push_back(Pair(s[i] - 'A', i));
    golems[i] = 1;
  }
  sort(table.begin(), table.end());
  for (int k = 0; k < Q; ++k) {
    char t, d;
    char str[2];
    scanf("%s", str);
    t = str[0];
    scanf("%s", str);
    d = str[0];
    Pair cmp = Pair(t - 'A', 0);
    vector<Pair>::iterator lb = lower_bound(table.begin(), table.end(), cmp);
    vector<Pair>::iterator ub = upper_bound(table.begin(), table.end(), cmp);
    for (vector<Pair>::iterator it = lb; it != ub; ++it) {
      int index = (*it).second;
      int golem_cnt = golems[index];
      golems[index] = 0;
      if (d == 'L' && index != 0) {
        golems[index - 1] += golem_cnt;
      } else if (d == 'R' && index != N - 1) {
        golems[index + 1] += golem_cnt;
      }
    }
  }
  int res = 0;
  for (int i = 0; i < N; ++i) res += golems[i];
  printf("%d\n", res);
}
