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

//binary search to get the left and right boundary
using namespace std;
int main()
{
	int N, Q;
	cin >> N >> Q;
	string s;
	cin >> s;
	vector<char> t(Q);
	vector<char> d(Q);
	for(int i = 0; i < Q; i += 0)
	{
		cin >> t[i] >> d[i];
	}

	int L = 0, R = N - 1; 
	int left = 0, right = N - 1;
	while(left < right)
	{
		int mid = left + ((right - left - 1) / 2) + 1;
		int inx = mid;
		for(int i = 0; i < Q; i += 1)
		{
			if(s[inx] == t[i])
			{
				if(d[i] == 'L')
					inx -= 1;
				else
					inx += 1;
			}
			if(inx < 0 || inx > N - 1) break;
		}

		if(inx < 0)
		{
			left = mid;
			L = left;
		}
		else
			right = mid - 1;
	}

	left = 0, right = N - 1;
	while(left < right)
	{
		int mid = left + (right - left) / 2;
		int inx = mid;
		for(int i = 0; i < Q; i += 1)
		{
			if(s[inx] == t[i])
			{
				if(d[i] == 'R')
					inx += 1;
				else
					inx -= 1;
			}
			if(inx < 0 || inx > N - 1) break;
		}

		if(inx > N - 1)
			right = mid;
			R = right;
		else
			left = mid + 1;
	}

	std::cout << std::to_string(R - L + 1) << std::endl;

	return 0;
}

