#include "bits/stdc++.h"

using namespace std;

void solve(void)
{
	int n, q;
	string s;
	cin >> n >> q >> s;
	vector<char> ts(q), ds(q);
	for (int i = 0; i < q; i++)
	{
		cin >> ts[i] >> ds[i];
	}
	int l = -1, r = n;
	while(l+1<r)
	{
		int m = (l + r) / 2, p = m;
		char t = s[p];
		for (int i = 0; i < q; i++)
		{
			if (ts[i] == t)
			{
				if (ds[i] == 'L')
				{
					p--;
				}
				else p++;
			}
			if (p < 0 || p >= n) break;
			t = s[p];
		}
		if (p < 0) l = m;
		else r = m;
	}
	int ans = n - l - 1;
	l = -1, r = n;
	while(l+1<r)
	{
		int m = (l + r) / 2, p = m;
		char t = s[p];
		for (int i = 0; i < q; i++)
		{
			if (ts[i] == t)
			{
				if (ds[i] == 'L')
				{
					p--;
				}
				else p++;
			}
			if (p < 0 || p >= n) break;
			t = s[p];
		}
		if (p >= n) r = m;
		else l = m;
	}
	ans -= n - r;
	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}
