#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
ll slide(vector<ll>& v, ll a, ll b) {
	ll azv = abs(v[0] - a);
	ll bzv = abs(v[0] - b);
	ll aov = abs(v[1] - a);
	ll bov = abs(v[1] - b);
	v[0] = a;
	v[1] = b;
	return max((azv + bov), (bzv + aov));
}

pair<char, int> qp[200010];
string s;
int lmemo[200010];
int rmemo[200010];

int n, q;
int check(int ind, int ro) {

	if (ind == -1) return -1;
	if (ind == n) return n;
	if (lmemo[ro] >= ind) return -1;
	if (rmemo[ro] <= ind) return n;
	if (q == ro) return 1;
	int res = 1;

	if (s[ind] == qp[ro].first) {
		res = check(ind + qp[ro].second, ro + 1);
	}
	else {
		res = check(ind, ro + 1);
	}

	if (res == -1) {
		lmemo[ro] = max(ind, lmemo[ro]);
	}
	if (res == n) {
		rmemo[ro] = min(ind, rmemo[ro]);
	}
	return res;
}
void solv() {

	cin >> n >> q;
	cin >> s;
	int qa[25];
	pii la[26];
	pii ra[26];
	fill(rmemo, rmemo + 200010, INF);
	fill(lmemo, lmemo + 200010, -1);
	for (size_t i = 0; i < 26; i++)
	{
		la[i].first = 0;
		la[i].second = 0;
		ra[i].first = n - 1;
		ra[i].second = n - 1;
	}
	for (size_t i = 0; i < q; i++)
	{
		char d, t;
		cin >> d >> t;
		int p = d - 'A';
		qp[i].first = d;
		qp[i].second = (t == 'L') ? -1 : 1;
		//if (t == 'L') {
		//	la[p].first++;
		//	la[p].second = max(la[p].first, la[p].second);
		//	ra[p].first++;
		//}
		//else {
		//	la[p].first--;
		//	ra[p].first--;
		//	ra[p].second = min(ra[p].first, ra[p].second);
		//}
	}
	bool bc = false;
	bool ac = false;
	int res = n;
	int fi = 0;
	int ai = n - 1;
	int fc = 0;
	while (fi <= ai) {
		if (!bc && check(fi, 0) == 1) {
			bc = true;
			res -= fi;
		}

		fi++;
		if (fi == ai) break;
		if (!ac && check(ai, 0) == 1) {
			ac = true;
			res -= n - (ai + 1);
		}
		ai--;
	}
	if (!bc) res -= fi;
	if (!ac) res -= n - fi;
	cout << res << endl;
}

int main() {
	//COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 14084