#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = mod * mod;
const long long d2 = (mod + 1) / 2;
const long double EPS = 1e-9;
const long double PI = acos(-1.0);
int ABS(int a) { return max(a, -a); }
long long ABS(long long a) { return max(a, -a); }
long double ABS(long double a) { return max(a, -a); }
char in[210000];
char S[210000];
char T[210000];
int main() {
  int a, b;
  scanf("%d%d", &a, &b);
  scanf("%s", in);
  for (int i = 0; i < b; i++) {
    scanf("%s%s", S + i, T + i);
  }
  int left = -1;
  int right = a;
  while (left + 1 < right) {
    int M = (left + right) / 2;
    int at = M;
    bool ok = false;
    for (int i = 0; i < b; i++) {
      if (S[i] == in[at]) {
        if (T[i] == 'L')
          at--;
        else
          at++;
      }
      if (at >= a) break;
      if (at < 0) {
        ok = true;
        break;
      }
    }
    if (ok) {
      left = M;
    } else
      right = M;
  }
  int L = left + 1;
  left = 0;
  right = a;
  while (left + 1 < right) {
    int M = (left + right) / 2;
    int at = M;
    bool ok = false;
    for (int i = 0; i < b; i++) {
      if (S[i] == in[at]) {
        if (T[i] == 'L')
          at--;
        else
          at++;
      }
      if (at >= a) {
        ok = true;
        break;
      }
      if (at < 0) {
        break;
      }
    }
    if (ok) {
      right = M;
    } else
      left = M;
  }
  int R = right - 1;
  printf("%d\n", max(0, R - L + 1));
}
