#include <bits/stdc++.h>
using namespace std;

int n, q;
string s;
vector<char> t(q), d(q);

int solve(int pos){
	for(int i = 0; i < q; ++i){
		if(s[pos] == t[i]){
			if(d[i]=='R'){
				pos++;
			}else{
				pos--;
			}
		}
		if(pos == -1) return -1;
		if(pos == n) return 1;
	}
	return 0;
}

int main(void){
	cin >> n >> q >> s;
	t.resize(q); d.resize(q);
	for(int i = 0; i < q; ++i){
		cin >> t[i] >> d[i];
	}
	int l, r;

	/* 
	 * Meguru's binary search
	 * [ok, ng)
	 */
	int ok = 0;
	int ng = n-1;
	while(abs(ok-ng)>1){
		int mid = (ok + ng) / 2;
		if(solve(mid) == -1){
			ok = mid;
		}else{
			ng = mid;
		}
	}
	l = ok; if(!solve(l)) l++;

	/* 
	 * Meguru's binary search 
	 * (ng,ok]
	 */
	ok = n-1;
	ng = 0;
	while(abs(ok-ng)>1){
		int mid = (ok + ng) / 2;
		if(solve(mid) == 1){
			ok = mid;
		}else{
			ng = mid;
		}
	}
	r = ok; if(!solve(r)) r++;

	//cout << l << " " << r << endl;
	cout << r-l-1 << endl;
	return 0;
}
