#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename V> typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V> typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }

typedef pair<int, int> P;
vector<vector<P> > V;
int N, Q;
string S;


bool lcheck(int mid) {
	if (mid == -1)return true;
	int cur = mid;
	int time = -1;
	while (cur != -1) {
		int dist = distance(V[S[cur]-'A'].begin(),upper_bound(ALL(V[S[cur] - 'A']), P(time, 0)));
		if (dist >= SZ(V[S[cur]-'A']))return false;
		time = V[S[cur] - 'A'][dist].first;
		cur += V[S[cur] - 'A'][dist].second;
		if (cur == -1)return true;
		if (cur == N)return false;
	}
	return false;
}
bool rcheck(int mid) {
	if (mid == N)return true;
	int cur = mid;
	int time = -1;
	while (cur != N) {
		int dist = distance(V[S[cur]-'A'].begin(), upper_bound(ALL(V[S[cur] - 'A']), P(time, 0)));
		if (dist >= SZ(V[S[cur] - 'A']))return false;
		time = V[S[cur] - 'A'][dist].first;
		cur += V[S[cur] - 'A'][dist].second;
		if (cur == -1)return false;
		if (cur == N)return true;
	}
	return false;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> Q;
	cin >> S;
	V = make_v<P>(26, 0);
	REP(i, Q) {
		char t, d;
		cin >> t >> d;
		V[t - 'A'].push_back(P(i, d == 'L' ? -1 : 1));
	}
	int ok = -1;
	int ng = N;
	lcheck(3);
	while (ng - ok > 1) {
		int mid = (ok + ng) / 2;
		if (lcheck(mid))ok = mid;
		else ng = mid;
	}
	int ans = ok + 1;
	ok = N;
	ng = -1;
	while (ok - ng > 1) {
		int mid = (ok + ng) / 2;
		if (rcheck(mid))ok = mid;
		else ng = mid;
	}
	ans += N - ok;
	cout << N - ans << endl;
	return 0;
}
