#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	int N, Q;
	std::cin >> N >> Q;
	std::string map;
	std::cin >> map;
	std::vector<std::pair<char, bool>> query(Q);
	for (auto& p : query)
	{
		char a, b;
		std::cin >> a >> b;
		p.first = a;
		p.second = b == 'R';
	}
	enum
	{
		alive,
		left_out,
		right_out
	};
	auto pred = [&](int i)
	{
		for (auto p : query)
		{
			if (p.first == map[i])
			{
				i += p.second ? 1 : -1;
			}
			if (i < 0)
			{
				return left_out;
			}
			else if (N <= i)
			{
				return right_out;
			}
		}
		return alive;
	};
	int out_left = -1;
	int out_right = N;
	int safe_left = N - 1;
	int safe_right = 0;
	while (std::max(safe_left - out_left, out_right - safe_right) >= 2)
	{
		auto i = (safe_left + out_left) / 2;
		auto result = pred(i);
		switch (result)
		{
		case alive:
			safe_left = i;
			break;
		case left_out:
			out_left = i;
			break;
		case right_out:
			out_right = i;
			break;
		}
		i = (safe_right + out_right) / 2;
		result = pred(i);
		switch (result)
		{
		case alive:
			safe_right = i;
			break;
		case left_out:
			out_left = i;
			break;
		case right_out:
			out_right = i;
			break;
		}
	}
	std::cout << safe_right - out_left << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}