#include <bits/stdc++.h>
using namespace std;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
int N, Q;
string s;
char t[200020], d[200020];
int check(int x) {
  for (int i = 0; i < Q; i++) {
    if (s[x] == t[i]) {
      if (d[i] == 'R') x++;
      if (d[i] == 'L') x--;
    }
    if (x == -1) return -1;
    if (x == N) return 1;
  }
  return 0;
}
int main() {
  cin >> N >> Q;
  cin >> s;
  for (int i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  int l = -1;
  int r = N;
  int mid;
  while (l <= r - 2) {
    mid = (l + r) / 2;
    if (check(mid) == -1)
      l = mid;
    else
      r = mid;
  }
  int z = l;
  l = -1;
  r = N;
  while (l < r - 1) {
    mid = (l + r) / 2;
    if (check(mid) == -1)
      l = mid;
    else
      r = mid;
  }
  int zz = r;
  cout << zz - z - 1 << endl;
}
