#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  string s;
  char t, d;
  cin >> N;
  int Go[N];
  int Gn[N];
  for (int i = 0; i < N; i++) {
    Go[i] = 1;
    Gn[i] = 1;
  }
  cin >> Q;
  cin >> s;
  while (Q != 0) {
    cin >> t >> d;
    for (int i = 0; i < N; i++) {
      if (s[i] == t) {
        if (d == 'R' && Go[i] != 0) {
          if (i != N - 1) {
            Gn[i + 1] = Go[i + 1] + Go[i];
            Gn[i] = Go[i] - Gn[i];
          } else
            Gn[i] = 0;
        } else if (d == 'L' && Go[i] != 0) {
          if (i != 0) {
            Gn[i - 1] = Gn[i - 1] + Go[i];
            Gn[i] = 0;
          } else
            Gn[i] = 0;
        }
      }
    }
    for (int i = 0; i < N; i++) Go[i] = Gn[i];
    Q--;
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += Go[i];
  }
  cout << ans << endl;
  return 0;
}
