#include <bits/stdc++.h>
#include <algorithm>
#include <stack>
using namespace std; 
int main(){
	int N, Q; cin >> N >> Q; 
	string S;
	cin >> S; 
	char T[200010] = {}; 
	char D[200010] = {}; 
	for(int i = 0; i < Q; i++){
		cin >> T[i] >> D[i]; 
	}
	int left = 0; int right = N; //左右から落ちる境界
	for(int i = Q - 1; i >= 0; i--){
		if(D[i] == 'L' && left <= N-1 && T[i] == S.at(left)){
			left ++; 
		} 
      	else if(D[i] == 'R' && left >= 1 && T[i] == S.at(left-1)){
			left --; 
		} 
		if(D[i] == 'R' && right >= 1 && T[i] == S.at(right-1)){
			right --; 
		} 
      	else if(D[i] == 'L' && right <= N-1 && T[i] == S.at(right)){
			right ++; 
		} 
      //cout << left << " " << right << endl; 
	} 
	cout << right - left << endl; 
}