#include <bits/stdc++.h>
#include <tr1/unordered_map>
#define ll long long
#define il inline
const ll inf = 1e9;

namespace io {

#define in(a) a = read()
#define out(a) write(a)
#define outn(a) out(a), putchar('\n')

#define I_int ll
inline I_int read() {
    I_int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
char F[200];
inline void write(I_int x) {
    if (x == 0) return (void) (putchar('0'));
    I_int tmp = x > 0 ? x : -x;
    if (x < 0) putchar('-');
    int cnt = 0;
    while (tmp > 0) {
        F[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while (cnt > 0) putchar(F[--cnt]);
}
#undef I_int

}
using namespace io;

using namespace std;

#define N 2000100

bool v[N];
int n,m,len1,len2;
char s[N];
char c[N][2];

int main() { memset(v,1,sizeof(v));
	in(n),in(m);scanf("%s",s+1);
	for(int i = 1; i <= m; ++i) {
		char s1[5],s2[5];
		scanf("%s%s",s1,s2);
		if(s2[0]=='L') c[++len1][0]=s1[0];
		else c[++len2][1]=s1[0];
	}
	int l = 1, r = len1;
	for(; r; --r) {
		if(c[r][0]==s[l]) {
			v[l++]=0;
		}
	}
	l = n, r = len2;
	for(; r;--r) {
		if(c[r][1]==s[l]) {
			v[l--]=0;
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; ++i) ans+=v[i];
	outn(ans);
}

/*
  AABCBDBA
0:11111111
1:10111120
2:01020202
3:01020200
*/
