#include <bits/stdc++.h>
using namespace std;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
long long n, q;
string s;
char t[200020], d[200020];
int solt(long long x) {
  for (int i = 0; i < q; i++) {
    if (s[x] == t[i]) {
      if (d[i] == 'L') x--;
      if (d[i] == 'R') x++;
    }
    if (x == -1) return 1;
    if (x == n) return 2;
  }
  return 0;
}
int main() {
  cin >> n >> q >> s;
  for (int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  long long mid;
  long long ls = -1;
  long long rs = n;
  while (ls < rs - 1) {
    mid = (ls + rs) / 2;
    if (solt(mid) == 1)
      ls = mid;
    else
      rs = mid;
  }
  long long lt = -1;
  long long rt = n;
  while (lt < ls - 1) {
    mid = (lt + rs) / 2;
    if (solt(mid) == 2)
      rt = mid;
    else
      lt = mid;
  }
  cout << rt - ls - 1 << endl;
  return 0;
}
