#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  char t[n], d[n];
  for (int i = 0; i < q; ++i) cin >> t[i] >> d[i];
  int min = -1, max = n;
  while (max - min > 1) {
    int mid = (max + min) / 2;
    int i = mid;
    bool ok = false;
    for (int j = 0; j < q; ++j)
      if (t[j] == s[i]) {
        i += (d[j] == 'R' ? 1 : -1);
        if (i == n) break;
        if (i == -1) {
          ok = true;
          break;
        }
      }
    (ok ? min : max) = mid;
  }
  int l = min;
  min = -1;
  max = n;
  while (max - min > 1) {
    int mid = (max + min) / 2;
    int i = n - 1 - mid;
    bool ok = false;
    for (int j = 0; j < q; ++j)
      if (t[j] == s[i]) {
        i += (d[j] == 'R' ? 1 : -1);
        if (i == -1) break;
        if (i == n) {
          ok = true;
          break;
        }
      }
    (ok ? min : max) = mid;
  }
  cout << n - l - 2 - min;
  return 0;
}
