//exawiz2019_c.cpp
//Sat Mar 30 20:43:05 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n,q;
	cin >> n >> q;
	string s;
	cin >> s;

	char t[q],d[q];
	for (int i=0;i<q;i++){
		cin >> t[i] >> d[i];
	}

	//Left.
	int left = 0;
	for (int i=q-1;i>=0;i--){
		if (t[i]==s[left] && d[i]=='L'){
			left++;
		}else if (left>0 && t[i]==s[left-1] && d[i]=='R'){
			left--;
		}
	}

	//Right.
	int right = n-1;
	for (int i=q-1;i>=0;i--){
		if (t[i]==s[right] && d[i]=='R'){
			right--;
		}else if (right<n-1 && t[i]==s[right+1] && d[i]=='L'){
			right++;
		}
	}

	if (left>right){
		cout << 0 << endl;
	}else {
		cout << n-(left + (n-1-right)) << endl;
	}

}