#include<iostream>
#include<string>
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define rep(i,n) FOR(i,0,n)
using namespace std;
using ll = long long;

int main(){
	int N,Q;
	string s;
	cin >>N>>Q>>s;
	char t[Q+10],d[Q+10];
	rep(i,Q)
		cin >>t[i]>>d[i];
	ll dp[Q+10][N+10] = {};
	rep(j,N)
		dp[0][j] = 1;

	rep(i,Q){
		rep(j,N){
			dp[i+1][j] = (s[j]==t[i])? 0 : dp[i][j];
			if(0<=j-1 && s[j-1]==t[i] && d[i]=='R')
				dp[i+1][j] += dp[i][j-1];
			if(j+1<=N-1 && s[j+1]==t[i] && d[i]=='L')
				dp[i+1][j] += dp[i][j+1];
		}
	}

	ll ans = 0;
	rep(j,N)
		ans += dp[Q][j];

	// rep(i,Q+1){
	// 	rep(j,N)
	// 		cout << dp[i][j] <<" ";
	// 	cout << endl;
	// }

	cout << ans << endl;
}

