#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N, Q;
  string S;
  char t[214514], d[214514];
  long long u[214514];
  cin >> N >> Q;
  cin >> S;
  for (long long i = 0; i < (Q); ++i) {
    cin >> t[i] >> d[i];
    u[i] = (long long)(t[i] - 'A');
  }
  long long F[214514] = {};
  for (long long i = 0; i < (N); ++i) {
    F[i] = 1;
  }
  vector<long long> G[30];
  for (long long i = 0; i < (N); ++i) {
    G[(long long)(S[i] - 'A')].push_back(i);
  }
  for (long long i = 0; i < (Q); ++i) {
    for (long long j = 0; j < (G[u[i]].size()); ++j) {
      long long c = G[u[i]][j];
      if (d[i] == 'L') {
        if (c > 0) {
          F[c - 1] += F[c];
        }
        F[c] = 0;
      } else {
        if (c < N - 1) {
          F[c + 1] += F[c];
        }
        F[c] = 0;
      }
    }
  }
  long long Ans = 0;
  for (long long i = 0; i < (N); ++i) {
    Ans += F[i];
  }
  cout << Ans << endl;
  return 0;
}
