#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  string S;
  cin >> N >> Q;
  cin >> S;
  vector<vector<char>> v(Q, vector<char>(2));
  for (int i = 0; i < Q; i++) {
    cin >> v[i][0] >> v[i][1];
  }
  vector<int> pos(N, 1);
  int pos_l, pos_r;
  bool zero = false;
  for (int i = 0; i < N; i++) {
    pos_l = i;
    for (int j = 0; j < Q; j++) {
      if (S[pos_l] == v[j][0]) {
        if (v[j][1] == 'L') {
          pos_l--;
          if (pos_l < 0) {
            break;
          }
        } else {
          pos_l++;
        }
      }
      if (pos_l > N - 1) {
        break;
        zero = true;
      }
    }
    if (pos_l >= 0) {
      pos_l = i;
      break;
    }
  }
  if (zero) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = N - 1; i >= 0; i--) {
    pos_r = i;
    for (int j = 0; j < Q; j++) {
      if (S[pos_r] == v[j][0]) {
        if (v[j][1] == 'R') {
          pos_r++;
          if (pos_r > N - 1) {
            break;
          }
        } else {
          pos_r--;
        }
      }
    }
    if (pos_r <= N - 1) {
      pos_r = i;
      break;
    }
  }
  if (pos_r - pos_l < 1)
    cout << 0 << endl;
  else
    cout << pos_r - pos_l + 1 << endl;
}
