#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int n,q;
string str;

int main() {
	cin >> n >> q;
	cin >> str;
	vector<pair<char,char> > arr(q);
	for(int i = 0; i < q; i++) {
		cin >> arr[i].first >> arr[i].second;
	}
	reverse(arr.begin(),arr.end());
	int l = 0;
	int r = n;
	for(pair<char,char> p : arr) {
		char al = p.first;
		char op = p.second;
		//cout << al << "," << op << endl;
		if(l<str.size() && str[l]==al && op=='L') {
			l++;
		}else if(l>0&&str[l-1]==al&&op=='R') {
			l--;
		}
		if(r>0 && str[r-1]==al && op=='R') {
			r--;
		}else if(r<str.size()&&str[r]==al&&op=='L') {
			r++;
		}
		//cout << l << "," << r << endl;
	}
	int ans = max(0,r-l);
	cout << ans << endl;

}
