#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, tmp;
  string s;
  char t[200001]{'0'}, d[200001]{'0'};
  vector<int> g;
  cin >> n >> q >> s;
  for (int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  for (int i = 0; i < s.size(); i++) {
    g.push_back(1);
  }
  for (int i = 0; i < q; i++) {
    for (int j = 0; j < g.size(); j++) {
      if (t[i] == s[j]) {
        if (d[i] == 'L') {
          if (j == 0)
            g[j] = 0;
          else {
            g[j - 1] += g[j];
            g[j] = 0;
          }
        } else {
          if (j == g.size() - 1)
            g[j] = 0;
          else {
            g[j + 1] += g[j];
            g[j] = 0;
          }
        }
      }
    }
  }
  tmp = 0;
  for (int i = 0; i < g.size(); i++) {
    tmp += g[i];
  }
  cout << tmp;
}
