#include <bits/stdc++.h>
using namespace std;
int n, q, sum = 0;
char s[200001];
char a;
char b;
int main() {
  cin >> n >> q;
  cin >> s;
  int line[n];
  for (int i = 0; i < n; ++i) {
    line[i] = 1;
  }
  for (int j = 0; j < q; ++j) {
    cin >> a >> b;
    for (int i = 0; i < n; ++i) {
      if (s[i] == a) {
        if (b == 'L' && i == 0) {
          line[i] = 0;
        } else if (b == 'L') {
          line[i - 1] += line[i];
          line[i] = 0;
        } else if (b == 'R' && i == n - 1) {
          line[i] = 0;
        } else if (b == 'R') {
          line[i + 1] += line[i];
          line[i] = 0;
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    sum += line[i];
  }
  cout << sum;
  return 0;
}
