#include <bits/stdc++.h>
using namespace std;
char t[200000], d[200000];
int n, q;
string s;
int simulate(int x) {
  for (int i = 0; i < q; i++) {
    if (s[x] == t[i]) {
      if (d[i] == 'L')
        x--;
      else
        x++;
      if (x < 0 || n <= x) break;
    }
  }
  return x;
}
int main() {
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
  int left = -1, right = n - 1;
  while (left + 1 < right) {
    int mid = (left + right) / 2;
    int p = simulate(mid);
    if (p == -1)
      left = mid;
    else
      right = mid;
  }
  int l = left;
  left = 0, right = n;
  while (left + 1 < right) {
    int mid = (left + right) / 2;
    int p = simulate(mid);
    if (p == n)
      right = mid;
    else
      left = mid;
  }
  int r = right;
  cout << n - ((l + 1) + (n - r)) << endl;
  return 0;
}
