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

const int MOD = (int)1e9+7;

int main(){
	int N,Q;
	string s;
	cin >> N >> Q >> s;
	vector<char> t(Q,'');
	vector<char> d(Q,'');
	for(int i=Q-1;i>=0;i--)	cin >> t.at(i) >> d.at(i);

	int left=-1;
	int right=N;
	for(int i=0;i<Q;i++){
		if(left+1<s.size() && t.at(i)==s.at(left+1) && d.at(i)=='L')	left++;
		if(right-1>=0 && t.at(i)==s.at(right-1) && d.at(i)=='R')	right--;
	}
	cout << max(0,right-left-1) << endl;
	
	return 0;
}
