#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<functional>
#include<limits.h>
#include<string.h>
#include<stack>
#include<list>
#include<deque>
#define int long long
#define mod 1000000007
using namespace std;

char a[300000], b[300000];
signed main() {
	int n, q; cin >> n >> q;
	string s; cin >> s;
	for (int i = 0; i < q; i++)cin >> a[i] >> b[i];
	int l = -1, r = n-1;
	while (r-l>1)
	{
		int t = (l + r) / 2; int u = t;
		for (int i = 0; i < q; i++) {
			if (s[t] == a[i]) {
				if (b[i] == 'L')t--;
				else t++;
				if (t < 0)break;
				if (t >= n) {
					r = u; goto k;
				}
			}
			if (i + 1 == q) {
				r = u; goto k;
			}
		}
		l = u;
	k:;
	}
	int ans = r;
	reverse(s.begin(), s.end());
	l = -1, r = n - 1;
	while (r - l>1)
	{
		int t = (l + r) / 2; int u = t;
		for (int i = 0; i < q; i++) {
			if (s[t] == a[i]) {
				if (b[i] == 'R')t--;
				else t++;
				if (t < 0)break;
				if (t >= n) {
					r = u; goto k;
				}
			}
			if (i + 1 == q) {
				r = u; goto w;
			}
		}
		l = u;
	w:;
	}
	cout << n - ans - r << endl;
}