#include <bits/stdc++.h>
using namespace std;
void fastStream() {
  cin.tie(0);
  std::ios_base::sync_with_stdio(0);
}
int N, Q;
string S;
char T[200010];
char D[200010];
bool ok[200010];
bool check_right(int pos) {
  for (int i = 0; i < Q; i++) {
    if (T[i] == S[pos]) {
      if (D[i] == 'L') pos--;
      if (D[i] == 'R') pos++;
    }
    if (pos >= N) return true;
  }
  return false;
}
bool check_left(int pos) {
  for (int i = 0; i < Q; i++) {
    if (T[i] == S[pos]) {
      if (D[i] == 'L') pos--;
      if (D[i] == 'R') pos++;
    }
    if (pos < 0) return true;
  }
  return false;
}
int main() {
  cin >> N >> Q;
  cin >> S;
  for (int i = 0; i < Q; i++) cin >> T[i] >> D[i];
  {
    int lb = -1;
    int ub = N - 1;
    while (ub - lb > 1) {
      int mid = (ub + lb) / 2;
      if (check_right(mid))
        ub = mid;
      else
        lb = mid;
    }
    for (int i = ub; i < N; i++) {
      ok[i] = true;
    }
  }
  {
    int lb = 0;
    int ub = N;
    while (ub - lb > 1) {
      int mid = (ub + lb) / 2;
      if (check_left(mid))
        lb = mid;
      else
        ub = mid;
    }
    for (int i = 0; i <= lb; i++) {
      ok[i] = true;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (ok[i]) ans++;
  }
  cout << N - ans << endl;
  return 0;
}
