#include <bits/stdc++.h>
using namespace std;
int elegantSolution(vector<char>& charVec, vector<char>& squareVec,
                    vector<char>& dirVec) {
  char lhs, rhs, c, d;
  lhs = charVec.front();
  rhs = charVec.back();
  int leftIdx = 0;
  int rightIdx = charVec.size() - 1;
  for (int i = squareVec.size() - 1; i >= 0; i--) {
    c = squareVec[i];
    d = dirVec[i];
    if (c == lhs && d == 'L') {
      leftIdx++;
      lhs = charVec[leftIdx];
      while (c == lhs) {
        leftIdx++;
        lhs = charVec[leftIdx];
      }
    }
    if (c == rhs && d == 'R') {
      rightIdx--;
      rhs = charVec[rightIdx];
      while (c == rhs) {
        rightIdx--;
        rhs = charVec[rightIdx];
      }
    }
  }
  int result = 0;
  if (rightIdx > leftIdx) {
    result = (rightIdx + 1) - leftIdx;
  }
  return result;
}
int main(int argc, const char* argv[]) {
  char c, d;
  int n, q;
  string str;
  cin >> n >> q;
  vector<char> charVec(n);
  vector<char> squareVec(q);
  vector<char> dirVec(q);
  cin >> str;
  for (int i = 0; i < str.size(); i++) {
    charVec[i] = str[i];
  }
  for (int j = 0; j < q; j++) {
    cin >> c >> d;
    squareVec[j] = c;
    dirVec[j] = d;
  }
  cout << elegantSolution(charVec, squareVec, dirVec) << endl;
  return 0;
}
