#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int N, Q;
char s[202020];
char t[202020];
char d[202020];
int f[202020];
int check(int p){
    for(int i = 0; i < Q; i++){
        if(s[p] == t[i]){
            if(d[i]=='L')p--;
            else p++;
        }
        if(p < 1)return 1;
        if(p > N)return 3;
    }
    return 2;
}

int main(){

    cin >> N >> Q;
    for(int i = 1; i <= N; i++)cin >> s[i];
    for(int i = 0; i < Q; i++)cin >> t[i] >> d[i];
    f[0] = 1;
    f[N+1] = 3;
    int notR = 0, R = N + 1;
    while(notR + 1 < R){
        int p = (notR + R) / 2;
        if(check(p) == 3)R = p;
        else notR = p;
    }
    int L = 0, notL = N + 1;
    while(L + 1 < notL){
        int p = (L + notL) / 2;
        if(check(p) == 1)L = p;
        else notL = p;
    }
    cout << max(0, notR - notL + 1) << endl;

    return 0;
}
