#include <bits/stdc++.h>
using namespace std;
int N, Q;
string S;
vector<char> T;
vector<char> D;
bool isOut(int mid, bool zero) {
  int pos = mid;
  bool out = false;
  for (int i = 0; i < (Q); i++) {
    if (S[pos] == T[i]) {
      pos += (D[i] == 'L') ? -1 : +1;
    }
    if (zero) {
      if (pos < 0) {
        out = true;
        break;
      }
    } else {
      if (N <= pos) {
        out = true;
        break;
      }
    }
  }
  return out;
}
int main(void) {
  ios::sync_with_stdio(false);
  cin >> N >> Q;
  cin >> S;
  T.resize(Q);
  D.resize(Q);
  for (int i = 0; i < (Q); i++) {
    cin >> T[i] >> D[i];
  }
  int left = 0;
  int right = min(Q, N - 1);
  while (left + 1 < right) {
    int mid = left + (right - left) / 2;
    if (isOut(mid, true)) {
      left = mid;
    } else {
      right = mid;
    }
  }
  int answer = N;
  if (isOut(left, true)) answer -= (left + 1);
  left = N - min(Q, N);
  right = N - 1;
  while (left + 1 < right) {
    int mid = left + (right - left) / 2;
    if (isOut(mid, false)) {
      right = mid;
    } else {
      left = mid;
    }
  }
  if (isOut(right, false)) answer -= (N - right);
  cout << answer << endl;
  return 0;
}
