#include <bits/stdc++.h>

using ll = long long;
constexpr ll inf = static_cast<ll>(1e15);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int n, q;
std::string s, ts, ds;
int main()
{
	std::cin >> n >> q;
	std::cin >> s;

	for (int i = 0; i < q; ++i) {
		char t, d;
		std::cin >> t >> d;
		ts += t;
		ds += d;
	}

	int l = 0, r = n - 1;
	for (int i = q - 1; i >= 0; --i) {
		if (ds[i] == 'L') {
			if (ts[i] == s[l])
				++l;
			if (r < n - 1 && ts[i] == s[r + 1])
				++r;
		}
		else {
			if (l > 0 && ts[i] == s[l - 1])
				--l;
			if (ts[i] == s[r])
				--r;
		}
	}

	std::cout << std::max(0, r - l + 1) << std::endl;
	return 0;
}
