#include <iostream>
#include <algorithm>
#include<cstring>
using namespace std;

int N, Q;
char s[200000];
char t[200000];
char d[200000];
int memo[200001][200000];


int search(int time, int i)
{
	if (memo[time][i] != -1)
		return memo[time][i];

	if (time == Q)
	{
		return memo[time][i] = i;
	}

	else
	{
		if (s[i] == t[time])
		{
			if (d[time] == 'L')
			{
				if (i == 0)
					return memo[time][i] = -2;
				else
					return search(time + 1, i - 1);
			}
			else
			{
				if (i == N - 1)
					return memo[time][i] = -2;
				else
					return search(time + 1, i + 1);
			}
		}
		else
		{
			return search(time + 1, i);
		}
	}
}


int main()
{
	cin >> N >> Q;
	memset(memo, -1, sizeof(memo));
	for (int i = 0; i < N; i++)
	{
		cin >> s[i];
	}

	for (int i = 0; i < Q; i++)
		cin >> t[i] >> d[i];

	int count = 0;

	for (int j = 0; j < N; j++)
	{
		int tmp = search(0, j);
		if (tmp >= 0)
			count++;
	}
	cout << count;
	return 0;
}