#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  char t[q], d[q];
  for (int i = 0; i < (q); i++) cin >> t[i] >> d[i];
  int alphabet[26][2000];
  int counter[26] = {};
  int g[n];
  for (int i = 0; i < (n); i++) {
    alphabet[s[i] - 'A'][counter[s[i] - 'A']] = i + 1;
    counter[s[i] - 'A']++;
    g[i] = 1;
  }
  for (int i = 0; i < (q); i++) {
    if (d[i] == 'R') {
      int j = 0;
      while (alphabet[t[i] - 'A'][j] != 0) {
        g[alphabet[t[i] - 'A'][j]] += g[alphabet[t[i] - 'A'][j] - 1];
        g[alphabet[t[i] - 'A'][j] - 1] = 0;
        j++;
      }
    } else {
      int j = 0;
      while (alphabet[t[i] - 'A'][j] != 0) {
        g[alphabet[t[i] - 'A'][j] - 2] += g[alphabet[t[i] - 'A'][j] - 1];
        g[alphabet[t[i] - 'A'][j] - 1] = 0;
        j++;
      }
    }
  }
  int res = 0;
  for (int i = 0; i < (n); i++) {
    res += g[i];
  }
  cout << res << endl;
}
