#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N,Q; cin >> N >> Q;
	string S; cin >> S;
	S = "*"+S+"*";
	int x = 0, y = N+1;
	int l = 0, r = N+1;
	vector<char> t(Q),d(Q);
	repp(i,0,Q) cin >> t[i] >> d[i];
	repm(i,Q-1,-1){
		if(d[i] == 'L'){
			if(S[l+1] == t[i]) ++l;
			if(S[r] == t[i]) ++r;
		} else {
			if(S[l] == t[i]) --l;
			if(S[r-1] == t[i]) --r;
		}
		x = max(x,l);
		y = min(y,r);
	}
	cout << N-min(N,l+N+1-r) << endl;
	return 0;
}
