#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
int N, Q;
string s;
vector<pair<char, char>> qs;
vector<int> ter;
int mv(int n) {
  if (ter[n] != -2) return ter[n];
  int Q = qs.size();
  int now = n;
  for (int i = 0; i < Q; i++) {
    if (qs[i].first == s[now]) {
      if (qs[i].second == 'L') now--;
      if (qs[i].second == 'R') now++;
    }
    if (now <= -1) return ter[n] = -1;
    if (now >= N) return ter[n] = N;
  }
  return ter[n] = now;
}
int main() {
  cin >> N >> Q;
  cin >> s;
  qs = vector<pair<char, char>>(Q);
  for (int i = 0; i < Q; i++) {
    cin >> qs[i].first >> qs[i].second;
  }
  ter = vector<int>(N, -2);
  int L = -1;
  int left = 0, right = N - 1;
  bool f1 = false;
  while (left < right) {
    int mid = (left + right + 1) / 2;
    if (ter[0] >= 0) {
      L = 0, f1 = true;
      break;
    }
    if (ter[N - 1] == -1) {
      L = N, f1 = true;
      break;
    }
    if (mv(mid) == -1)
      left = mid;
    else
      right = mid - 1;
  }
  if (!f1) L = left + 1;
  int R = -1;
  left = 0, right = N - 1;
  bool f2 = false;
  while (left < right) {
    int mid = (left + right) / 2;
    if (ter[0] == N) {
      R = N, f2 = true;
      break;
    }
    if (ter[N - 1] != -2 && ter[N - 1] < N) {
      R = 0, f2 = true;
      break;
    }
    if (mv(mid) == N)
      right = mid;
    else
      left = mid + 1;
  }
  if (!f2) R = N - right;
  cout << N - min(N, L + R) << endl;
}
