#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
static int n, q;
static string s;
static char t[200010], d[200010];
bool f(int loc, int T) {
  if (loc <= -1 || loc >= n) return true;
  if (T == q + 1) return false;
  if (t[T] == s[loc]) {
    if (d[T] == 'L')
      loc--;
    else
      loc++;
  }
  return f(loc, T + 1);
}
int main() {
  scanf("%d%d", &n, &q);
  cin >> s;
  for (int i = 1; i <= q; i++) {
    scanf("\n");
    scanf("%s %s", &t[i], &d[i]);
  }
  int l = 0, r = n;
  while (l < r) {
    int m = (l + r + 1) / 2;
    if (f(m - 1, 1))
      l = m;
    else
      r = m - 1;
  }
  int l_ = 1, r_ = n + 1;
  while (l_ < r_) {
    int m = (l_ + r_) / 2;
    if (f(m - 1, 1))
      r_ = m;
    else
      l_ = m + 1;
  }
  cout << l_ - 1 - l << endl;
}
