#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  vector<vector<pair<int, int>>> vec(26);
  string s;
  cin >> s;
  vector<char> t(q), d(q);
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
  int lb = 0;
  int ub = n;
  while (ub - lb > 1) {
    int mid = (ub + lb) / 2;
    int pos = mid - 1;
    for (int i = 0; i < q; i++) {
      if (s[pos] == t[i]) {
        if (d[i] == 'R')
          pos++;
        else
          pos--;
        if (pos < 0 || pos >= n) {
          break;
        }
      }
    }
    if (pos < 0)
      lb = mid;
    else
      ub = mid;
  }
  int res = lb;
  lb = 0;
  ub = n + 1;
  while (ub - lb > 1) {
    int mid = (ub + lb) / 2;
    int pos = mid - 1;
    for (int i = 0; i < q; i++) {
      if (s[pos] == t[i]) {
        if (d[i] == 'R')
          pos++;
        else
          pos--;
        if (pos < 0 || pos >= n) {
          break;
        }
      }
    }
    if (pos == n)
      ub = mid;
    else
      lb = mid;
  }
  res += n - lb;
  cout << n - res << endl;
  return 0;
}
