#include <bits/stdc++.h>
using namespace std;
int getint() {
  char C;
  while (!isdigit(C = getchar_unlocked()))
    ;
  int x = C - '0';
  while (isdigit(C = getchar_unlocked())) x = x * 10 + C - '0';
  return x;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, Q;
  N = getint();
  Q = getint();
  char S[200000];
  for (int i = 0; i < (N); i++) S[i] = getchar_unlocked();
  char T[200000], D[200000];
  for (int i = 0; i < (Q); i++) {
    getchar_unlocked();
    T[i] = getchar_unlocked();
    getchar_unlocked();
    D[i] = getchar_unlocked();
    ;
  }
  int L = 0;
  int R = N - 1;
  for (int i = Q - 1; i >= 0; i--) {
    if (R > 0 && D[i] == 'R' && S[R] == T[i])
      R--;
    else if (R < N && D[i] == 'L' && S[R + 1] == T[i])
      R++;
    if (L > 0 && D[i] == 'R' && S[L - 1] == T[i])
      L--;
    else if (L < N && D[i] == 'L' && S[L] == T[i])
      L++;
  }
  cout << (R - L + 1) << "\n";
  return 0;
}
