#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  struct Spel {
    char c;
    int d;
  };
  vector<Spel> spels(q);
  for (auto& spel : spels) {
    char c, d;
    cin >> c >> d;
    spel.c = c;
    spel.d = (d == 'L') ? -1 : 1;
  }
  int p_l = 0;
  int p_r = n - 1;
  for (auto it = spels.rbegin(); it != spels.rend(); it++) {
    int c = it->c;
    int d = it->d;
    if (p_l < n) {
      if (c == s[p_l] && d == -1) {
        p_l++;
      }
    }
    if (0 <= p_r) {
      if (c == s[p_r] && d == 1) {
        p_r--;
      }
    }
  }
  int fall_count = 0;
  if (n < p_l) fall_count = n;
  if (p_r < 0)
    fall_count = n;
  else {
    int fall_l = p_l;
    int fall_r = (n - 1 - p_r);
    fall_count = min(n, fall_l + fall_r);
  }
  cout << (n - fall_count) << endl;
  return 0;
}
