#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

// x番目のゴーレムをk番目のマスに移動させられるか確認する
bool checkLeft(int x, int k, string &s, vector<char> &t, vector<char> &d)
{
	for(int i = 0; i < t.size(); ++i)
	{
		if(t[i] == s[x])
		{
			x += (d[i] == 'L' ? -1 : 1);
		}

		if(s[x] == '_')
		{
			return x == k;
		}
	}

	return false;
}

int main()
{
	int n, q;
	string s;

	cin >> n >> q;
	cin >> s;

	s = "_" + s + "_";

	vector<char > t(q);
	vector<vector<char> > d(2, vector<char>(q));
	for(int i = 0; i < q; ++i)
	{
		cin >> t[i] >> d[0][i];
		d[1][i] = (d[0][i] == 'L' ? 'R' : 'L');
	}

	int golem = n;
	for(int i = 0; i < 2; ++i)
	{
		int lb = 0, m, ub = n + 1;
		while(ub - lb > 1)
		{
			m = (ub + lb) / 2;
			(checkLeft(m, 0, s, t, d[i]) ? lb : ub) = m;
		}

		reverse(s.begin(), s.end());

		golem -= lb;
	}

	cout << golem << endl;
}