import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int solve (int n, int q, string s, char [2] [] orders)
{
	int lo = 0;
	int hi = s.length.to !(int) - 1;

	int go (int pos)
	{
		foreach (const ref order; orders)
		{
			if (order[0] == s[pos])
			{
				pos += ((order[1] == 'L') ? -1 : +1);
			}
		}
		return pos;
	}

	int lo1 = lo;
	int hi1 = hi;
	while (lo1 < hi1)
	{
		int me1 = (lo1 + hi1 + 1) / 2;
		if (go (me1) == 0)
		{
			lo1 = me1;
		}
		else
		{
			hi1 = me1 - 1;
		}
	}

	int lo2 = lo;
	int hi2 = hi;
	while (lo2 < hi2)
	{
		int me2 = (lo2 + hi2 + 0) / 2;
		if (go (me2) == hi)
		{
			hi2 = me2;
		}
		else
		{
			lo2 = me2 + 1;
		}
	}
	return max (0, lo2 - lo1 - 1);
}

void main ()
{
	int n, q;
	while (readf (" %s %s", &n, &q) > 0)
	{
		readln;
		auto s = readln.strip;
		s = '*' ~ s ~ '*';
		auto orders = new char [2] [q];
		foreach (ref order; orders)
		{
			readf (" %c %c", &order[0], &order[1]);
		}
		writeln (solve (n, q, s, orders));
	}
}
