#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q, result, Ncp;
  string s;
  cin >> N >> Q >> s;
  vector<int> res(N, 1);
  result = 0;
  if (N < Q) {
    Ncp = N;
  } else {
    Ncp = Q;
  }
  for (int i = 0; i < Q; i++) {
    char ti, di;
    cin >> ti >> di;
    if (di == 'L') {
      for (int j = 0; j < Ncp; j++) {
        if (s[j] == ti) {
          if (j == 0) {
            res[j] = 0;
          } else {
            res[j - 1] += res[j];
            res[j] = 0;
          }
        }
      }
    } else if (di == 'R') {
      for (int j = N - 1; j >= 0; j--) {
        if (s[j] == ti) {
          if (j == N - 1) {
            res[j] = 0;
          } else {
            res[j + 1] += res[j];
            res[j] = 0;
          }
        }
      }
    }
  }
  for (int i = 0; i < N; i++) {
    result += res[i];
  }
  cout << result << endl;
}
