#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q, i, j, count, check, min, maxi, fm;
  fm = 100000000;
  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 < i && j < fm) break;
        }
      }
      if (check < 0) {
        j--;
        break;
      }
    }
    if (j == Q) {
      min = i;
      break;
    }
  }
  for (i = 0; i < N; i++) {
    fm = 100000000;
    check = N - i - 1;
    for (j = 0; j < Q; j++) {
      if (S[check] == t[j][0]) {
        if (d[j][0] == 'R') {
          check++;
          if (check > N - i - 1 && j < fm) break;
        } else {
          check--;
        }
      }
      if (check == N) {
        j--;
        break;
      }
    }
    if (j == Q) {
      maxi = i;
      break;
    }
  }
  count = max(N - min - maxi, 0);
  cout << count << endl;
}
