#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = 1ll << 61;
struct edge {
  long long to;
  long long to2;
  long long cost;
};
string qt, qd;
signed main() {
  long long n, q;
  cin >> n >> q;
  string X;
  cin >> X;
  string s = "%";
  s += X;
  s.push_back('%');
  for (long long i = 0; i < q; i++) {
    char t, d;
    cin >> t >> d;
    qt.push_back(t);
    qd.push_back(d);
  }
  long long lb = 0, ub = n + 1;
  while (ub - lb > 1) {
    long long mi = (lb + ub) / 2;
    char nlt = s[mi];
    long long pos = mi;
    for (long long i = 0; i < q; i++) {
      if (pos == 0) break;
      if (nlt == qt[i]) {
        if (qd[i] == 'L') {
          pos--;
          nlt = s[pos];
        } else if (qd[i] == 'R') {
          pos++;
          nlt = s[pos];
        }
      }
    }
    if (pos == 0)
      lb = mi;
    else
      ub = mi;
  }
  long long lb2 = 0, ub2 = n + 1;
  while (ub2 - lb2 > 1) {
    long long mi = (lb2 + ub2) / 2;
    char nlt = s[mi];
    long long pos = mi;
    for (long long i = 0; i < q; i++) {
      if (pos == n + 1) break;
      if (nlt == qt[i]) {
        if (qd[i] == 'L') {
          pos--;
          nlt = s[pos];
        } else if (qd[i] == 'R') {
          pos++;
          nlt = s[pos];
        }
      }
    }
    if (pos == n + 1)
      ub2 = mi;
    else
      lb2 = mi;
  }
  cout << n - lb2 + ub << endl;
}
