#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>


using namespace std;

const long long N = 2e5 + 5;
long long n, q;
char a[N];
char c[N];
char d[N];

bool isval1(long long k)
{
	long long pos = k;
	for (long long i = 0; i < q; i++)
	{
		if (a[pos] == c[i])
		{
			if (d[i] == 'L')
			{
				pos--;
			}
			else
			{
				pos++;
			}
			if (pos == -1)
				return true;
			if (pos == n)
				return false
		}
	}
	return false;
}

long long bsearch1()
{
	long long down = -1;
	long long up = n;
	while (up - down > 1)
	{
		long long md = (up + down) / 2;
		if (isval1(md))
		{
			down = md;
		}
		else
		{
			up = md;
		}
	}
	return down;
}

bool isval2(long long k)
{
	long long pos = k;
	for (long long i = 0; i < n; i++)
	{
		if (a[pos] == c[i])
		{
			if (d[i] == 'L')
			{
				pos++;
			}
			else
			{
				pos--;
			}
			if (pos == -1)
				return true;
			if (pos == n)
				return false;
		}
	}
	return false;
}

long long bsearch2()
{
	long long down = -1;
	long long up = n;
	while (up - down > 1)
	{
		long long md = (up + down) / 2;
		if (isval2(md))
		{
			down = md;
		}
		else
		{
			up = md;
		}
	}
	return down;
}




 
int main() 
{
	cin >> n >> q;
	for (long long i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (long long i = 0 ; i < q; i++)
	{
		cin >> c[i] >> d[i];
	}
	long long ans = 0;
	ans = bsearch1();
	reverse(a, a + n);
	ans += bsearch2();
	ans++;
	ans++;
	cout << n - ans << endl;


}


 
