#include <bits/stdc++.h>
using namespace std;
int N, Q;
string S;
vector<char> T(200200), D(200200);
int solve(int X) {
  for (long long i = 0; i < (Q); i++) {
    if (X == -1 or X == N) break;
    if (S[X] == T[i]) {
      if (D[i] == 'L')
        X--;
      else
        X++;
    }
  }
  if (X == -1) return -1;
  if (X == N) return 1;
  return 0;
}
int main() {
  cin >> N >> Q;
  cin >> S;
  for (long long i = 0; i < (Q); i++) cin >> T[i] >> D[i];
  int ans = N;
  int ok = N;
  int ng = 0;
  for (long long i = 0; i < (20); i++) {
    if (abs(ok - ng) <= 1) break;
    int mid = (ok + ng) / 2;
    if (solve(mid) == 1)
      ok = mid;
    else
      ng = mid;
  }
  ans -= N - ok;
  ok = -1;
  ng = N - 1;
  for (long long i = 0; i < (20); i++) {
    if (abs(ok - ng) <= 1) break;
    int mid = (ok + ng) / 2;
    if (solve(mid) == -1)
      ok = mid;
    else
      ng = mid;
  }
  ans -= ok + 1;
  cout << ans << endl;
}
