// ConsoleApplication1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include "pch.h"
#include<iostream>
#include<algorithm>
#include<limits.h>
#include<map>
#include<vector>
#include<string>
using namespace std;
vector<string> vec;
int main()
{
	int len, n;
	cin >> len >> n;
	vec.resize(len);
	for (int i = 0; i < len; i++)
	{
		char c;
		cin >> c;
		vec[i] = c;
	}
	for (int i = 0; i < n; i++)
	{
		char b, m;
		scanf("\n%c %c", &b, &m);
		if (m == 'L')
		{
			for (int j = 0; j < len; j++)
			{
				if (count(vec[j].begin(), vec[j].end(), b) != 0)
				{
					if (j != 0)
						vec[j - 1] += vec[j];
					vec[j] = "";
				}
			}
		}
		else
		{
			for (int j = len - 1; j >= 0; j--)
			{
				if (count(vec[j].begin(), vec[j].end(), b) != 0)
				{
					if (j != len - 1)
						vec[j + 1] += vec[j];
					vec[j] = "";
				}
			}
		}

		/*cout << i << ". ";
		for (auto str : vec)
		{
			cout << str << " ";
		}
		cout << endl;*/
	}
	int ans = 0;
	for (int i = 0; i < len; i++)
	{
		ans += vec[i].length();
	}
	cout << ans;
	return 0;
}