#include <bits/stdc++.h>
using namespace std;
int N;
bool check(int n) {
  if (n >= 0 && n < N)
    return true;
  else
    return false;
};
int main() {
  int 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;
  int pos_l_max = -1, pos_r_min = N;
  bool zero = false;
  bool start = false;
  for (int i = Q - 1; i >= 0; i--) {
    if (v[i][0] == S[0] && v[i][1] == 'L' && start == false) {
      pos_l = 0;
      pos_l_max = 0;
      start = true;
    } else if (start) {
      if (v[i][1] == 'L' && check(pos_l + 1)) {
        if (S[pos_l + 1] == v[i][0]) pos_l++;
      } else if (v[i][1] == 'R' && check(pos_l - 1)) {
        if (S[pos_l - 1] == v[i][0]) pos_l--;
      }
      if (pos_l > pos_l_max) pos_l_max = pos_l;
      if (pos_l > N - 1 || pos_l < 0) {
        break;
        zero = true;
      }
    }
  }
  start = false;
  for (int i = Q - 1; i >= 0; i--) {
    if (v[i][0] == S[N - 1] && v[i][1] == 'R' && start == false) {
      pos_r = N - 1;
      pos_r_min = N - 1;
      start = true;
    } else if (start) {
      if (true) {
        if (v[i][1] == 'L' && check(pos_r + 1)) {
          if (S[pos_r + 1] == v[i][0]) pos_r++;
        } else if (v[i][1] == 'R' && check(pos_r - 1)) {
          if (S[pos_r - 1] == v[i][0]) pos_r--;
        }
      }
      if (pos_r < pos_r_min) pos_r_min = pos_r;
      if (pos_r > N - 1 || pos_r < 0) {
        break;
        zero = true;
      }
    }
  }
  if (zero) {
    cout << 0 << endl;
    return 0;
  }
  if (pos_r_min - pos_l_max < 1)
    cout << 0 << endl;
  else
    cout << pos_r_min - pos_l_max - 1 << endl;
}
