#include <cstdio>
#include <algorithm>

const int MN = 200005;
const int MM = 200005;

int N, M;
char s[MN];
char c1[MM][3], c2[MM][3];

int main() {
	scanf("%d%d", &N, &M);
	scanf("%s", s + 1);
	for (int i = 1; i <= M; ++i)
		scanf("%s%s", c1[i], c2[i]);
	int lb = 0, rb = 0;
	for (int i = M; i >= 1; --i) {
		if (*c2[i] == 'L') {
			if (s[lb + 1] == *c1[i]) ++lb;
			if (rb && s[N - rb + 1] == *c1[i]) --rb;
		}
		if (*c2[i] == 'R') {
			if (s[N - rb] == *c1[i]) ++rb;
			if (lb && s[lb] == *c1[i]) --lb;
		}
		if (lb + rb >= N) break;
	}
	printf("%d\n", std::max(N - lb - rb, 0));
	return 0;
}