#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int n, q;
vector<char> t(200010);
vector<char> d(200010);
string s;


int main() {
	cin >> n >> q >> s;
	for (int i = 0; i < q; i++)
	{
		cin >> t[i] >> d[i];
	}
	int beg = -1;
	int end = n;
	//呪文配列を後ろから操作
	for (int i = q-1; i >=0; i--)
	{
		if (beg>=-1&&t[i] == s[beg+1] && d[i] == 'L') {
			beg++;
		}
		if (beg>=0&&t[i] == s[beg] && d[i] == 'R') {
			beg--;
		}
		if (beg == n - 1) {
			break;
		}
	}
	for (int i = q - 1; i >= 0; i--)
	{
		if (end<=n&&t[i] == s[end-1] && d[i] == 'R') {
			end--;
		}
		if (end<=n-1&&t[i] == s[end] && d[i] == 'L') {
			end++;
		}
		if (end == 0) {
			break;
		}
	}
	int ans = 0;
	if (beg>=end)
	{
		ans = 0;
	}else {
		ans = end - beg - 1;
	}
	cout << ans << endl;
}