#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 10;
int N, Q;
string s;
int S[MAX];
int t[MAX], d[MAX];
bool alive(int n, bool left) {
  for (long long q = 0; q < Q; q++)
    if (S[n] == t[q]) {
      n += d[q];
      if (left) {
        if (n < 0) return false;
      } else {
        if (n >= N) return false;
      }
    }
  return true;
}
int main() {
  cin >> N >> Q >> s;
  for (long long i = 0; i < N; i++) S[i] = s[i] - 'A';
  for (long long q = 0; q < Q; q++) {
    char tt, dd;
    cin >> tt >> dd;
    t[q] = tt - 'A';
    d[q] = (dd == 'L') ? -1 : 1;
  }
  int l = -1, r = N - 1;
  while (r - l > 1) {
    int m = (r + l) / 2;
    if (alive(m, true))
      r = m;
    else
      l = m;
  }
  int left = l;
  l = 0, r = N;
  while (r - l > 1) {
    int m = (r + l) / 2;
    if (alive(m, false))
      l = m;
    else
      r = m;
  }
  cout << r - left - 1 << endl;
}
