#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  char t[q], d[q];
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
  if (n == 1) {
    for (int i = 0; i < q; i++) {
      if (t[i] == s[0]) cout << 0 << endl;
      return 0;
    }
    cout << 1 << endl;
    return 0;
  }
  int l = -1, r = n;
  int ll = -1, lr = -1;
  for (int i = q - 1; i >= 0; i--) {
    if (t[i] == s[l + 1] && d[i] == 'L') {
      l++;
      ll = i;
    }
    if (t[i] == s[r - 1] && d[i] == 'R') {
      r--;
      lr = i;
    }
    if (l == r - 1) break;
  }
  int sum = 0;
  for (int i = lr - 1; i >= 0; i--) {
    if (t[i] == s[r] && d[i] == 'L')
      r++;
    else if (t[i] == s[r - 1] && d[i] == 'R')
      r--;
  }
  for (int i = ll - 1; i >= 0; i--) {
    if (t[i] == s[l] && d[i] == 'R')
      l--;
    else if (t[i] == s[l + 1] && d[i] == 'L')
      l++;
  }
  cout << n - (l + 1 + n - r) << endl;
}
