#include <bits/stdc++.h>
using namespace std;
const long long MAX = 510000;
const long long MOD = 998244353;
signed main() {
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  char t[q], d[q];
  for (long long i = 0; i < q; i++) cin >> t[i] >> d[i];
  long long ng = -1, ok = n, mid;
  while (abs(ok - ng) > 1) {
    mid = (ok + ng) / 2;
    for (long long i = 0; i < q && mid != ok && mid != ng; i++) {
      if (t[i] == s[mid]) {
        if (d[i] == 'L')
          mid--;
        else
          mid++;
      }
    }
    if (mid == ok)
      ok = (ok + ng) / 2;
    else
      ng = (ok + ng) / 2;
  }
  long long ans = ok;
  ng = -1;
  ok = n;
  while (abs(ok - ng) > 1) {
    mid = (ok + ng) / 2;
    for (long long i = 0; i < q && mid != ok && mid != ng; i++) {
      if (t[i] == s[mid]) {
        if (d[i] == 'L')
          mid--;
        else
          mid++;
      }
    }
    if (mid == ng)
      ng = (ok + ng) / 2;
    else
      ok = (ok + ng) / 2;
  }
  cout << ans - ok << endl;
}
