/*
 * SAD
 */
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using orderd_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define S second
#define F first
#define pb push_back
const int inf = 1e9;
using ii = pair<int, int>;
using ll = long long;
using db = long double;

const int N = 1e5 + 5, M = 1000 * 1000 * 10 + 5, K = 55, Base = 27, MOD = 1e9
		+ 7, MOD2 = 998244353;
const ll MX = 1e15;
const int blkSz = 200;
const db EPS = 1e-7;
const int PI = 3;
int mx[26], mn[26], cur[26];
int main() {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	
	int n, m;
	cin >> n >> m;
	string s;
	cin >> s;
	while(m--){
		char c,L;
		cin >> c >> L;
		if(L == 'L')
			cur[c-'A']--;
		else
			cur[c-'A']++;
		mx[c-'A'] = max(mx[c-'A'], cur[c-'A']);
		mn[c-'A'] = min(mn[c-'A'], cur[c-'A']);			
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(i + mn[s[i]-'A'] >= 0 && i + mx[s[i]-'A'] < n)
			ans++;
	}
	cout << ans << '\n';
	return 0;
}
