#include <bits/stdc++.h>
using namespace std;
int solve(vector<int>& inVec, map<char, vector<int>>& map,
          vector<char>& squareVec, vector<char>& dirVec, char lhs, char rhs) {
  char c, d;
  int golems = 0;
  int stopIdx = squareVec.size();
  for (int i = 0; i < squareVec.size(); i++) {
    c = squareVec[i];
    d = dirVec[i];
    if (c == lhs && d == 'L') {
      stopIdx = i + 1;
    } else if (c == rhs && d == 'R') {
      stopIdx = i + 1;
    }
  }
  for (int i = 0; i < stopIdx; i++) {
    c = squareVec[i];
    d = dirVec[i];
    for (int j = 0; j < map[c].size(); j++) {
      golems = inVec[map[c][j]];
      inVec[map[c][j]] = 0;
      if (d == 'L') inVec[map[c][j] - 1] += golems;
      if (d == 'R') inVec[map[c][j] + 1] += golems;
    }
  }
  int count = 0;
  for (int i = 1; i < inVec.size() - 1; i++) {
    count += inVec[i];
  }
  return count;
}
int main(int argc, const char* argv[]) {
  char c, d;
  int n, q;
  cin >> n >> q;
  vector<int> inVec(n + 2);
  map<char, vector<int>> myMap;
  char lhs, rhs;
  for (int i = 0; i < n; i++) {
    cin >> c;
    myMap[c].push_back(i + 1);
    inVec[i + 1] = 1;
    if (i == 0) {
      lhs = c;
    } else if (i == n - 1) {
      rhs = c;
    }
  }
  vector<char> squareVec(q);
  vector<char> dirVec(q);
  for (int j = 0; j < q; j++) {
    cin >> c >> d;
    squareVec[j] = c;
    dirVec[j] = d;
  }
  cout << solve(inVec, myMap, squareVec, dirVec, lhs, rhs) << endl;
  return 0;
}
