#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int N, Q;
string s;

char t[200005], d[200005];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> Q >> s;

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

	int idx = -1;
	for (int i = Q-1;i >= 0;i--){
		if(idx != N-1 && s[idx+1] == t[i] && d[i] == 'L'){
			idx++;
		}else if(idx != -1 && s[idx] == t[i] && d[i] == 'R'){
			idx--;
		}
	}

	int ans = idx+1;

	idx = N;
	for (int i = Q-1;i >= 0;i--){
		if(idx != 0 && s[idx-1] == t[i] && d[i] == 'R'){
			idx--;
		}else if(idx != N && s[idx] == t[i] && d[i] == 'L'){
			idx++;
		}
	}

	ans += N-idx;

	cout << max(0,N-ans) << endl;

	return 0;

}
