#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

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

	vector<pair<char, char>> a(q);
	rep(i, q) {
		char s, t;
		cin >> s >> t;
		a[i] = make_pair(s, t);
	}

	s = "@@" + s + "@@";
	int left = -1e9, right = 1e9;
	int cur = 1;
	for (int i = q - 1; i >= 0; i--) {
		if (a[i].second == 'L') {
			if (s[cur + 1] == a[i].first) { cur++; }
		} else {
			if (s[cur - 1] == a[i].first) { cur--; }
		}
		left = max(left, cur);
	}

	cur = s.size() - 2;
	for (int i = q - 1; i >= 0; i--) {
		if (a[i].second == 'L') {
			if (s[cur + 1] == a[i].first) { cur++; }
		} else {
			if (s[cur - 1] == a[i].first) { cur--; }
		}
		right = min(right, cur);
	}

	//cout << left << ' ' << right << endl;
	cout << n - (left - 1 + s.size() - 2 - right) << endl;
}
