#include <bits/stdc++.h>
using namespace std;
char a[300000], b[300000];
signed main() {
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  for (long long i = 0; i < q; i++) cin >> a[i] >> b[i];
  long long l = -1, r = n - 1;
  while (r - l > 1) {
    long long t = (l + r) / 2;
    long long u = t;
    for (long long i = 0; i < q; i++) {
      if (s[t] == a[i]) {
        if (b[i] == 'L')
          t--;
        else
          t++;
        if (t < 0 || t >= n) break;
      }
      if (i + 1 == q) {
        r = u;
        goto k;
      }
    }
    l = u;
  k:;
  }
  long long ans = r;
  reverse(s.begin(), s.end());
  l = -1, r = n - 1;
  while (r - l > 1) {
    long long t = (l + r) / 2;
    long long u = t;
    for (long long i = 0; i < q; i++) {
      if (s[t] == a[i]) {
        if (b[i] == 'R')
          t--;
        else
          t++;
        if (t < 0 || t >= n) break;
      }
      if (i + 1 == q) {
        r = u;
        goto w;
      }
    }
    l = u;
  w:;
  }
  cout << n - ans - r << endl;
}
