#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int N, Q;
string s;
char t[223456], d[223456];

// 左に消えるかどうか
bool isOK(int idx){
	set<char> se;
	se.insert(s[idx]);
	int current = idx;
	rep(i, Q){
		if (se.count(s[idx])){
			if (d[i] == 'L') current--;
			else current++;
			se.insert(s[current]);
			if (current < 0) return true;
		}
	}
	return false;
}

// 右に消えるかどうか
bool isOK2(int idx){
	set<char> se;
	se.insert(s[idx]);
	int current = idx;
	rep(i, Q){
		if (se.count(s[idx])){
			if (d[i] == 'L') current--;
			else current++;
			se.insert(s[current]);
			if (current >= N) return true;
		}
	}
	return false;
}


signed main(){

	cin >> N >> Q;
	cin >> s;

	int amin[26], amax[26], current[26];
	rep(i, 26){
		amin[i] = INF;
		amax[i] = -INF;
		current[i] = 0;
	}
	rep(i, Q){
		cin >> t[i] >> d[i];
		int idx = t[i] - 'A';
		if (d[i] == 'L')
			current[idx]--;
		else
			current[idx]++;
	}

	// 左側から何番目までが左に消えるか
	int ng = -1;
	int ok = N;

	while (abs(ok - ng) > 1){
		int mid = (ok + ng) / 2;
		if (isOK(mid)) ok = mid;
		else ng = mid;
	}
	int left = ok;


	// 右側から何番目までが左に消えるか
	int ng = -1;
	int ok = N;

	while (abs(ok - ng) > 1){
		int mid = (ok + ng) / 2;
		if (isOK2(mid)) ok = mid;
		else ng = mid;
	}
	cout << N - left - ok << endl;

	return 0;
}