#include <iostream>
#include <vector>

using namespace std;

int N, Q;
string str;
vector<char> t, d;

int is_down(int k) {
	int pos = k;
	for (int i = 0; i < Q; i++) {
		if (pos == -1 || pos == N) return pos;
		if (str[pos] == t[i]) {
			if (d[i] == 'L') pos--;
			else pos++;
		}
	}
	return pos;
}


int main() {

	cin >> N >> Q;
	cin >> str;
	
	for (int i = 0; i < Q; i++)
	{
		char tmp1, tmp2;
		cin >> tmp1 >> tmp2;
		t.push_back(tmp1);
		d.push_back(tmp2);
	}

	//左に落ちないゴーレムのうち、最も左端のものを二分探索
	int left= -1, right = N;
	while (left +1 < right) {
		int mid = (left + right) / 2;
		if (is_down(mid) == -1) left = mid;
		else right = mid;
	}
	int remainL = right;

	//右に落ちないゴーレムのうち、最も右端のものを二分探索
	left = -1, right = N;
	while (left + 1 < right) {
		int mid = (left + right) / 2;
		if (is_down(mid) == N) right = mid;
		else left = mid;
	}
	int remainR = left;
	int ans = remainR - remainL + 1;

	cout << ans << endl;

	return 0;
}