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

int N, Q;
char s[200002], t[200000], d[200000];

int judge(int x){
	if(x == 0) return -1;
	if(x == N+1) return 1;
	for(int i=0; i<Q; i++){
		if(s[x] == t[i]){
			if(d[i] == 'L') x--;
			else x++;
			if(x <= 0) return -1;
			if(x > N) return 1;
		}
	}
	return 0;
}

int search_left(void){
	int i = 0, j = N+1;
	while(j-i > 1){
		int m = (i+j)/2;
		if(judge(m) >= 0) j = m;
		else i = m;
	}
	return j;
}

int search_right(void){
	int i = 0, j = N+1;
	while(j-i > 1){
		int m = (i+j)/2;
		if(judge(m) == 1) j = m;
		else i = m;
	}
	return j;
}

int main(){
	cin >> N >> Q;
	for(int i=1; i<=N; i++) cin >> s[i];
	for(int i=0; i<Q; i++) cin >> t[i] >> d[i];
	cout << search_right() - search_left() << endl;
	return 0;
}
