#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q, i, j, count, check;
  count = 0;
  string S;
  cin >> N >> Q;
  cin >> S;
  string t[Q];
  string d[Q];
  for (i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  for (i = 0; i < N; i++) {
    check = i;
    for (j = 0; j < Q; j++) {
      if (S[check] == t[j][0]) {
        if (d[j][0] == 'R') {
          check++;
        } else {
          check--;
        }
      }
      if (check < 0 || check == N) {
        count++;
        break;
      }
    }
  }
  cout << N - count << endl;
}
