#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const unsigned long long BS1 = 10000019ULL;
const int INF = (1 << 29);
template <class T>
inline void fastScan(T &x) {
  register char c = getchar();
  int neg = 0;
  x = 0;
  for (; (c < 48 || c > 57) && (c != '-'); c = getchar())
    ;
  if (c == '-') {
    neg = 1;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x = -x;
}
int n, Q;
int kunt[N + N];
char s[N + N];
vector<int> v[30];
int main() {
  fastScan(n);
  fastScan(Q);
  scanf("%s", s);
  for (int i = 0; i < n; i++) {
    v[s[i] - 'A'].push_back(i);
    kunt[i] = 1;
  }
  while (Q--) {
    char t[2], d[2];
    scanf("%s %s", t, d);
    int idx = t[0] - 'A';
    vector<int> tmp = v[idx];
    v[idx].clear();
    for (int i = 0; i < tmp.size(); i++) {
      int what = tmp[i];
      int how = kunt[what];
      kunt[what] = 0;
      if (d[0] == 'L') {
        what--;
      } else {
        what++;
      }
      if (what >= 0 && what < n) {
        v[s[what] - 'A'].push_back(what);
        kunt[what] += how;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < N + N; i++) {
    ans += kunt[i];
  }
  printf("%d\n", ans);
}
