#include <bits/stdc++.h>
using namespace std;
signed main() {
  int64_t N, Q;
  cin >> N >> Q;
  vector<char> S(N + 1, '-'), T(Q), D(Q);
  for (int64_t(i) = 0; (i) < (N); (i)++) cin >> S[i + 1];
  for (int64_t(i) = 0; (i) < (Q); (i)++) cin >> T[i] >> D[i];
  int64_t ans = N;
  int64_t ok = 0, ng = N + 1;
  while (ng - ok > 1) {
    int64_t mid = (ok + ng) / 2;
    int64_t idx = mid;
    bool leftside = false;
    for (int64_t(i) = 0; (i) < (Q); (i)++) {
      if (S[idx] == T[i]) {
        if (D[i] == 'R')
          idx++;
        else
          idx--;
      }
      if (idx == 0) {
        leftside = true;
        break;
      } else if (idx == N)
        break;
    }
    if (leftside)
      ok = mid;
    else
      ng = mid;
  }
  ans -= ok;
  ok = N + 1, ng = 0;
  while (ok - ng > 1) {
    int64_t mid = (ok + ng) / 2;
    int64_t idx = mid;
    bool rightside = false;
    for (int64_t(i) = 0; (i) < (Q); (i)++) {
      if (S[idx] == T[i]) {
        if (D[i] == 'R')
          idx++;
        else
          idx--;
      }
      if (idx == N + 1) {
        rightside = true;
        break;
      } else if (idx == 0)
        break;
    }
    if (rightside)
      ok = mid;
    else
      ng = mid;
  }
  ans -= N + 1 - ok;
  cout << ans << endl;
}
