#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<string> t(Q);
  vector<string> d(Q);
  for (int i = 0; i < Q; i++) cin >> t[i] >> d[i];
  vector<int> a(N, 1);
  vector<int> b(N, 1);
  for (int i = 0; i < Q; i++) {
    for (int j = 0; j < N; j++) {
      if (t[i][0] == s[j]) {
        if (d[i] == "R") {
          if (j + 1 != N) {
            b[j + 1] += a[j];
          }
          b[j] -= a[j];
        } else {
          if (j - 1 >= 0) {
            b[j - 1] += a[j];
          }
          b[j] -= a[j];
        }
      }
    }
    for (int i = 0; i < N; i++) a[i] = b[i];
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    count += a[i];
  }
  cout << count << endl;
  return 0;
}
