#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	long long N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	long long i, j, k;
	vector<char> T;
	vector<char> D;
	for (i = 0; i < Q; i++) {
		char t, d;
		cin >> t >> d;
		T.push_back(t);
		D.push_back(d);
	}
	reverse(T.begin(), T.end());
	reverse(D.begin(), D.end());
	//まずは左にはみ出す上限を検討
	long long L_depth = 0;
	i = 0;
	while (i < Q) {
		if (S.at(L_depth) == T.at(i) && D.at(i) == 'L') {
			L_depth++;
		}
		else if (S.at(L_depth) == T.at(i) && D.at(i) == 'R'&&L_depth != 0) {
			//break;
		}
		i++;
	}
	long long R_depth = N - 1;
	i = 0;
	while (i < Q) {
		if (S.at(R_depth) == T.at(i) && D.at(i) == 'R') {
			R_depth--;
		}
		else if (S.at(R_depth) == T.at(i) && D.at(i) == 'L' && R_depth != N - 1) {
			//break;
		}
		i++;
	}
	long long zero = 0;
	cout << max(R_depth - L_depth + 1,zero);