#include <bits/stdc++.h>
using namespace std;
const int maxn = 222;
const int maxs = 200100;
const int mod = 1000000007;
char t[maxn], d[maxn];
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
  int tot = 0;
  int lo = 0, hi = n - 1, ans = -1;
  while (lo <= hi) {
    int mid = (lo + hi) / 2;
    int pv = mid;
    for (int i = 0; i < q && pv > -1 && pv < n; i++)
      if (s[pv] == t[i]) {
        if (d[i] == 'L')
          pv--;
        else
          pv++;
      }
    if (pv < 0)
      ans = mid, lo = mid + 1;
    else
      hi = mid - 1;
  }
  tot += ans + 1;
  lo = 0, hi = n - 1, ans = -1;
  while (lo <= hi) {
    int mid = (lo + hi) / 2;
    int pv = mid;
    for (int i = 0; i < q && pv > -1 && pv < n; i++)
      if (s[pv] == t[i]) {
        if (d[i] == 'L')
          pv--;
        else
          pv++;
      }
    if (pv >= n)
      ans = mid, hi = mid - 1;
    else
      lo = mid + 1;
  }
  if (ans != -1) tot += n - ans;
  cout << n - tot << endl;
  return 0;
}
