#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int n, q;
string s;
char t[202020], d[202020];

int main(){
	cin >> n >> q;
	cin >> s;
	for(int i = 0; i < q; i++){
		cin >> t[i] >> d[i];
	}
	
	int l = 0, r = n-1;
	int ansl = 0, ansr = 0;
	while(l <= r){
		int c = (l+r)/2, cc = (l+r)/2;
		for(int i = 0; i < q; i++){
			if(t[i] == s[c]){
				if(d[i] == 'L') c--;
				else c++;
			}
			if(c < 0){
				l = cc+1;
				ansl = cc+1;
				break;
			}
		}
		if(l != cc+1) r = cc-1;
	}
	
	l = ansl; r = n-1;
	while(l <= r){
		int c = (l+r)/2, cc = (l+r)/2;
		for(int i = 0; i < q; i++){
			if(t[i] == s[c]){
				if(d[i] == 'L') c--;
				else c++;
			}
			if(c >= n){
				r = cc-1;
				ansr = n-cc;
				break;
			}
		}
		if(r != cc-1) l = cc+1;
	}
	
	cout << n-(ansl + ansr) << endl;
	
	return 0;
}