#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  int mas[n + 2];
  for (int i = 1; i < n + 1; i++) {
    mas[i] = 1;
  }
  mas[0] = 0;
  mas[n + 1] = 0;
  string s;
  cin >> s;
  for (int i = 0; i < q; i++) {
    char t, d;
    cin >> t >> d;
    for (int j = 1; j < n + 1; j++) {
      if (s[j - 1] == t) {
        int pre_mas = mas[j];
        mas[j] -= pre_mas;
        if (d == 'R')
          mas[j + 1] += pre_mas;
        else
          mas[j - 1] += pre_mas;
      }
    }
  }
  cout << n - mas[0] - mas[n + 1] << endl;
  return 0;
}
