#include <bits/stdc++.h>
using namespace std;
int n, q;
string s;
char t[200000 + 10], d[200000 + 10];
bool left(int pos) {
  for (int i = 0; i < q; i++) {
    if (s[pos] == t[i]) {
      if (d[i] == 'L')
        pos--;
      else
        pos++;
    }
    if (pos == -1) return true;
  }
  return false;
}
bool right(int pos) {
  for (int i = 0; i < q; i++) {
    if (s[pos] == t[i]) {
      if (d[i] == 'L')
        pos--;
      else
        pos++;
    }
    if (pos == n) return true;
  }
  return false;
}
int main() {
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < q; i++) {
    scanf(" %c %c", &t[i], &d[i]);
  }
  int l1 = 0, r1 = n - 1;
  while (l1 <= r1) {
    int mid = l1 + (r1 - l1) / 2;
    if (left(mid))
      l1 = mid + 1;
    else
      r1 = mid - 1;
  }
  int l2 = 0, r2 = n - 1;
  while (l2 <= r2) {
    int mid = (r2 + l2) / 2;
    if (right(mid))
      r2 = mid - 1;
    else
      l2 = mid + 1;
  }
  printf("%d\n", n - (n - l2 + 1 + r1 + 1));
  return 0;
}
