#include <bits/stdc++.h>

using namespace std;

pair<char, char> a[222222];
int main() {
	int n, q;
	string s;
	cin >> n >> q >> s;
	for (int i = 0; i < q; i++) {
		char t, d;
		scanf(" %c %c", &t, &d);
		a[i] = { t,d };
	}
	int l = 0, r = n + 1;
	while (l + 1 < r) {
		int m = (l + r) / 2, k = m;
		for (int i = 0; i < q; i++) {
			if (a[i].first == s[k - 1])
				a[i].second == 'L' ? k-- : k++;
			if (!k || k > n) break;
		}
		if (k) r = m;
		else l = m;
	}
	int x = l;
	l = 0, r = n + 1;
	while (l + 1 < r) {
		int m = (l + r) / 2, k = m;
		for (int i = 0; i < q; i++) {
			if (a[i].first == s[k - 1])
				a[i].second == 'L' ? k-- : k++;
			if (!k || k > n) break;
		}
		if (k > n) r = m;
		else l = m;
	}
	cout << r - x - 1 << endl;
	return 0;
}
