#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long i, j, n, q, golem = 0;
  string s;
  char found, shift;
  cin >> n >> q >> s;
  long long len = s.length(), GolArr[len];
  for (i = 0; i < len; i++) {
    GolArr[i] = 1;
  }
  while (q--) {
    cin >> found >> shift;
    for (i = 0; s[i]; i++) {
      if (s[i] == found) {
        if (i == 0 && shift == 'L')
          GolArr[i] = 0;
        else if (i == n - 1 && shift == 'R')
          GolArr[i] = 0;
        else {
          if (shift == 'L') {
            GolArr[i - 1] += GolArr[i];
            GolArr[i] = 0;
          } else {
            GolArr[i + 1] += GolArr[i];
            GolArr[i] = 0;
          }
        }
      }
    }
  }
  for (i = 0; i < len; i++) golem += GolArr[i];
  cout << golem << endl;
  return 0;
}
