#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int N,Q;
	string str;
	cin >> N >> Q >> str;

	int left = -1, right = N;

	vector<char>t(Q), d(Q);
	for (int i = 0; i < Q; i++) {
		cin >> t[i] >> d[i];
	}

	for (int i = Q - 1; i >= 0; i--) {
		//左端落下増える
		if(left < N -1 && str[left + 1] == t[i] && d[i] == 'L')left++;
		//左端落下減る
		if (left >= 0 && str[left] == t[i] && d[i] == 'R') left--;
		//右端落下増える
		if(right > 0 && str[right - 1] == t[i] && d[i] == 'R') right--;
		//右端落下減る
		if (right < N && str[right] == t[i] && d[i] == 'L') right++;

		if (right == 0 || left == N -1) break;
	}

	int ans = N - min(left + 1 + N - right, N);
	
	cout << ans << endl;

	return 0;
}