#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const ll mod = 1000000000 + 7;
typedef pair<char, char> CP;

ll max(ll a, ll b){
	if (a>b) return a;
	else return b;
}

ll min(ll a, ll b){
	if (a<b) return a;
	else return b;
}

int main() {
	ll n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<CP> cp(q);
	REP(i, q){cin >> cp[i].first >> cp[i].second;}
	ll l = 0; ll r = n-1;
	REPR(i, q){
		if (cp[i].second == 'L'){
			if (cp[i].first == s[l]){
				l++;
			}
			if (cp[i].first == s[min(r+1, n-1)]){
				r = min(r+1, n-1);
			}
		} else {
			if (cp[i].first == s[r]){
				r--;
			}
			if (cp[i].first == s[max(l-1, 0)]){
				l = max(l-1, 0);
			}
		}
	}
	cout << n - l - (n-1-r) << endl;
}
