#include <bits/stdc++.h>

using namespace std;

int n, m;

char ch[200010];

int A[200010], B[200010];

int Do(int x) {
	for(int i = 1; i <= m; i++)
		if(ch[x] == A[i]) {
			x += B[i];
			if(x == 0 || x == n + 1) return x;
	}
	return x;
}

int main() {
scanf("%d%d", &n, &m);
	scanf("%s", ch + 1);
	for(int i = 1; i <= m; i++) {
		char X[3], Y[3];
		scanf("%s%s", X, Y);
		A[i] = X[0], B[i] = Y[0] == 'R' ? 1 : -1;
	}
	int ansL = 0;
	for(int l = 1, r = n; l <= r; ) {
		int md = (l + r) / 2;
		if(Do(md) == 0) ansL = md, l = md + 1; else r = md - 1;
	}
	int ansR = n + 1;
	for(int l = 1, r = n; l <= r; ) {
		int md = (l + r) / 2;
		if(Do(md) != n + 1) l = md + 1; else ansR = md, r = md - 1;
	}
	printf("%d\n", ansR - ansL - 1);
	return 0;
}