#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void init(T& x) {
  x = 0;
  char ch = getchar();
  bool t = 0;
  for (; ch > '9' || ch < '0'; ch = getchar())
    if (ch == '-') t = 1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = (x << 1) + (x << 3) + (ch - 48);
  if (t) x = -x;
  return;
}
int n, Q;
const int N = 1e5 + 10;
char S[N];
char opt[N];
int LR[N];
inline char Gc() {
  char ch = getchar();
  while (!(ch >= 'A' && ch <= 'Z')) ch = getchar();
  return ch;
}
inline bool checkL(int p) {
  for (int i = 1; i <= Q; ++i) {
    if (opt[i] == S[p]) p += LR[i];
    if (p <= 0) return 1;
    if (p > n) return 0;
  }
  return 0;
}
inline bool checkR(int p) {
  for (int i = 1; i <= Q; ++i) {
    if (opt[i] == S[p]) p += LR[i];
    if (p > n) return 1;
    if (p <= 0) return 0;
  }
  return 0;
}
int main() {
  init(n), init(Q);
  scanf("%s", S + 1);
  for (int i = 1; i <= Q; ++i) {
    char ch = Gc();
    opt[i] = ch;
    ch = Gc();
    LR[i] = (ch == 'L') ? (-1) : 1;
  }
  int l = 1, r = n, pos = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (checkL(mid))
      pos = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  int ans = pos;
  l = pos + 1, r = n;
  pos = n + 1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (checkR(mid))
      pos = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  ans += (n - pos + 1);
  cout << (n - ans) << endl;
  return 0;
}
