# include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn(2e5 + 5);

int n, q, ans;
char s[maxn], t[maxn], d[maxn];

inline int check(int x) {
	int i;
	for (i = 1; i <= q && x && x <= n; ++i) if (t[i] == s[x]) d[i] == 'L' ? --x : ++x;
	return x;
}

int main() {
	scanf("%d%d %s", &n, &q, s + 1);
	int i, l, r, mid, ret1 = 0, ret2 = n + 1;
	for (i = 1; i <= q; ++i) scanf(" %c %c", &t[i], &d[i]);
	l = 1, r = n;
	while (l <= r) {
		mid = (l + r) >> 1;
		if (check(mid) < 1) ret1 = mid, l = mid + 1;
		else r = mid - 1;
	}
	l = 1, r = n;
	while (l <= r) {
		mid = (l + r) >> 1;
		if (check(mid) > n) ret2 = mid, r = mid - 1;
		else l = mid + 1;
	}
	printf("%d\n", n - min(n, ret1 + n - ret2 + 1));
    return 0;
}