#include <bits/stdc++.h>
using namespace std;
signed main() {
  signed N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  char t[Q];
  char d[Q];
  for (long long i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  long long ans_l;
  long long ans_r;
  for (long long i = 0; i < N; i++) {
    long long pos = i;
    long long flag = N;
    for (long long j = 0; j < Q; j++) {
      if (s[pos] == t[j]) {
        if (d[j] == 'R') {
          pos++;
        } else {
          pos--;
        }
        if (pos < 0) {
          break;
        }
        if (pos > N - 1) {
          flag = 1;
          ans_l = i;
          break;
        }
        if (N - pos > Q - j) {
          break;
        }
      }
    }
    if (flag) {
      break;
    }
  }
  for (long long i = N - 1; i >= 0; i--) {
    long long pos = i;
    long long flag = 0;
    for (long long j = 0; j < Q; j++) {
      if (s[pos] == t[j]) {
        if (d[j] == 'R') {
          pos++;
        } else {
          pos--;
        }
        if (pos > N - 1) {
          break;
        }
        if (pos < 0) {
          flag = 1;
          ans_r = i;
          break;
        }
        if (pos + 1 > Q - j) {
          break;
        }
      }
    }
    if (flag) {
      break;
    }
  }
  if (ans_l > ans_r) {
    cout << N - (N - ans_l + ans_r + 1) << endl;
  } else {
    cout << "0" << endl;
  }
  return 0;
}
