#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int q;
  cin >> q;
  vector<char> s1;
  string s;
  cin >> s;
  vector<int> glm;
  for (int i = 0; i < n; i++) {
    glm.push_back(1);
    s1.push_back(s[i]);
  }
  vector<char> t1;
  vector<char> d1;
  for (int j = 0; j < q; j++) {
    char t, d;
    cin >> t >> d;
    t1.push_back(t);
    d1.push_back(d);
  }
  for (int k = 0; k < q; k++) {
    if (d1[k] == 'L') {
      for (int i = 0; i < n; i++) {
        if (s1[i] == t1[k]) {
          if (i != 0) {
            glm[i - 1] = glm[i - 1] + glm[i];
            glm[i] = 0;
          } else {
            glm[0] = 0;
          }
        }
      }
    } else {
      for (int j = n - 1; 0 <= j; j--) {
        if (s1[j] == t1[k]) {
          if (j != n - 1) {
            glm[j + 1] = glm[j + 1] + glm[j];
            glm[j] = 0;
          } else {
            glm[n - 1] = 0;
          }
        }
      }
    }
  }
  int num = 0;
  for (int p = 0; p < n; p++) {
    num = num + glm[p];
  }
  cout << num;
  system("pause");
  return 0;
}
