#include <bits/stdc++.h>

#define INF INT_MAX
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

int n,q;

bool isRange(int a){
	return 0 <= a && a < n; 
}

int main(){
	cin.tie(0);
  	ios::sync_with_stdio(false);

	cin >> n >> q;

	string s;
	cin >> s;

	vector<pair<char,char>> td;
	int t,d;
	for(int i=0;i < q;i++){
		char t,d;
		cin >> t >> d;
		td.push_back(make_pair(t,d));
	}

	int l = -1;
	int r = n;
	for(int i = td.size()-1;i >= 0;i--){
		char t = td[i].first, d = td[i].second;
		// cout << t << " " << d << " " << s[l+1] << " " << s[r-1] << endl;
		if(isRange(l+1) && s[l+1] == t && d == 'L'){
			l++;
		}else if(isRange(l) && s[l] == t && d == 'R'){
			l--;
		}
		if(isRange(r-1) && s[r-1] == t && d == 'R'){
			r--;
		}else if(isRange(r) && s[r] == t && d == 'L'){
			r++;
		}
	}
	// cout << l << " " << r << endl;
	cout << n-(l+1)-(n-r) << endl;
   
	return 0;
}
