#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  unsigned int i = 0;
  char *t;
  int *d;
  t = new char[Q];
  d = new int[Q];
  while (i < N) {
    char c;
    cin >> t[i] >> c;
    if (c == 'R')
      d[i] = 1;
    else
      d[i] = -1;
    ++i;
  }
  int *Num;
  Num = new int[N];
  i = 0;
  while (i < N) {
    Num[i] = 1;
    ++i;
  }
  i = 0;
  int j, PrevNum, PrevItr;
  while (i < Q) {
    j = 0;
    PrevNum = 0;
    PrevItr = 0;
    while (j < N) {
      if (s[j] == t[i]) {
        if (j + d[i] < 0) {
          Num[0] = 0;
        } else if (j + d[i] >= N) {
          Num[N - 1] = 0;
        } else {
          if (PrevItr == j) {
            Num[j + d[i]] += (Num[j] - PrevNum);
            PrevNum = Num[j] - PrevNum;
          } else {
            Num[j + d[i]] += Num[j];
            PrevNum = Num[j];
          }
          Num[j] = 0;
          PrevItr = j + d[i];
        }
      }
      ++j;
    }
    ++i;
  }
  i = 0;
  unsigned int res = 0;
  while (i < N) {
    res += Num[i];
    ++i;
  }
  cout << res << endl;
  return 0;
}
