#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, q;
  cin >> n >> q;
  char s[n + 1];
  cin >> s;
  char t[q], d[q];
  for (int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  int p = 0;
  int res_l = 0, res_r = 0;
  ;
  char prev = '0';
  for (int i = q - 1; i >= 0; i--) {
    if (t[i] == s[p] && d[i] == 'L') {
      p++;
      prev = s[p - 1];
      res_l++;
    } else if (t[i] == prev && d[i] == 'R') {
      p = 0;
      res_l = 0;
      prev = '0';
    }
  }
  p = n - 1;
  prev = '0';
  for (int i = q - 1; i >= 0; i--) {
    if (t[i] == s[p] && d[i] == 'R') {
      p--;
      prev = s[p + 1];
      res_r++;
    } else if (t[i] == prev && d[i] == 'L') {
      p = n - 1;
      res_r = 0;
      prev = '0';
    }
  }
  cout << n - (res_l + res_r) << endl;
  return 0;
}
