#include <bits/stdc++.h>
#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)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(begin(v), end(v))
#define REV(v) reverse(begin(v), end(v))
#define VI vector<int>
#define PB(x) push_back(x)
#define SZ(x) end(x) - begin(x)
#define DEBUG(x) cerr << __LINE__ << ":" << #x << ": " << x << "\n";
//#define int long long
using namespace std;
using lint = long long;
struct Fast{Fast(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};} fast;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
inline void CO(auto &a) {REP(i, SZ(a)) cout << i << ": " << a[i] << "\n";}
//if (IO > 1e5){lint a;	scanf(%lld, &a);	printf("%lld\n", a);}

signed main(){
	int n,q;	cin >> n >> q;
	string s;	cin >> s;
	VI g(n,1);	//number of Golem
	vector<char> t(q);
	vector<char> d(q);
	
	REP(i,q) 	cin >> t[i] >> d[i];
	
	REP(i,q){
		REP(j,n){
			if (t[i] == s[j]){
				if (d[i] == 'L'){
					if (j != 0)	g[j-1] += g[j];
					g[j] = 0;
				}else{
					if (j != (n-1))	g[j+1] += g[j];
					g[j] = 0;
				}
			}
		}
	}
	
	FOR(i,1,n)	g[0] += g[i];
	cout << g[0] << endl;
return 0;
}
