#include <iostream>
#include <string>
using namespace std;

char t[200009], d[200009];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, q; cin >> n >> q;
	string s; cin >> s;
	int ts = -1, te = n;
	for (int i = 0; i < q; i++)
		cin >> t[i] >> d[i];
	for (int i = q - 1; i >= 0; i--) {
		if (te - ts <= 1) break;
		if (d[i] == 'L') {
			if (ts < n - 1 && s[ts + 1] == t[i]) ts++;
			if (te < n && s[te] == t[i]) te++;
		}
		else {
			if (0 <= ts && s[ts] == t[i]) ts--;
			if (0 < te && s[te - 1] == t[i]) te--;
		}
	}
	cout << n - (ts + 1 + n - te) << '\n';
	return 0;
}