#include <bits/stdc++.h>
using namespace std;
signed main(void) {
  long long N, Q;
  long long res = 0;
  cin >> N >> Q;
  long long count[N];
  char s[N];
  char t[Q];
  char d[Q];
  for (long long i = 0; i < N; i++) {
    cin >> s[i];
    count[i] = 1;
  }
  for (long long i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  for (long long i = 0; i < Q; i++) {
    if (d[i] == 'L') {
      for (long long j = 0; j < N; j++) {
        if (s[j] == t[i]) {
          if (j == 0) {
            count[0] = 0;
          } else {
            count[j - 1] = count[j - 1] + count[j];
            count[j] = 0;
          }
        }
      }
    } else {
      for (long long j = N - 1; j >= 0; j--) {
        if (s[j] == t[i]) {
          if (j == N - 1) {
            count[N - 1] = 0;
          } else {
            count[j + 1] = count[j + 1] + count[j];
            count[j] = 0;
          }
        }
      }
    }
  }
  for (long long i = 0; i < N; i++) {
    res = res + count[i];
  }
  cout << res << endl;
  return 0;
}
